[Insight-users] Problem with static linking ITK

Balske at t-online.de Balske at t-online.de
Tue Jul 27 06:40:13 EDT 2010


Hello,
first of all, sorry for my last mail, I forgot to set my Email to plain text.

I have a problem with static linking ITK to a project. I build ITK with shared disabled on an Ubuntu system and 
my target link libs look like this (ordered like in my CMake):

TARGET_LINK_LIBRARIES(myProject
Static_Libs/Itk/bin/libITKAlgorithms.a
Static_Libs/Itk/bin/libITKBasicFilters.a
Static_Libs/Itk/bin/libITKCommon.a
Static_Libs/Itk/bin/libITKDICOMParser.a
Static_Libs/Itk/bin/libITKEXPAT.a
Static_Libs/Itk/bin/libITKFEM.a
Static_Libs/Itk/bin/libitkgdcm.a
Static_Libs/Itk/bin/libITKIO.a
Static_Libs/Itk/bin/libitkjpeg12.a
Static_Libs/Itk/bin/libitkjpeg16.a
Static_Libs/Itk/bin/libitkjpeg8.a
Static_Libs/Itk/bin/libITKMetaIO.a
Static_Libs/Itk/bin/libitkNetlibSlatec.a
Static_Libs/Itk/bin/libITKniftiio.a
Static_Libs/Itk/bin/libITKNrrdIO.a
Static_Libs/Itk/bin/libITKNumerics.a
Static_Libs/Itk/bin/libitkopenjpeg.a
Static_Libs/Itk/bin/libitkpng.a
Static_Libs/Itk/bin/libITKSpatialObject.a
Static_Libs/Itk/bin/libITKStatistics.a
Static_Libs/Itk/bin/libitksys.a
Static_Libs/Itk/bin/libitktestlib.a
Static_Libs/Itk/bin/libitktiff.a
Static_Libs/Itk/bin/libitkv3p_lsqr.a
Static_Libs/Itk/bin/libitkv3p_netlib.a
Static_Libs/Itk/bin/libitkvcl.a
Static_Libs/Itk/bin/libitkvnl.a
Static_Libs/Itk/bin/libitkvnl_algo.a
Static_Libs/Itk/bin/libitkvnl_inst.a
Static_Libs/Itk/bin/libitkzlib.a
Static_Libs/Itk/bin/libITKznz.a)

(I removed "/home/user/" in lib paths because I like my anonymity :) )

All I do in my actual project is to construct an itk::Image, so it is more like a test run to check
if static linking works:

#include "itkImage.h"

int main(int argc, char *argv[]) {

        typedef itk::Image< unsigned short, 3 > ImageType;
        ImageType::Pointer image = ImageType::New();

        return 1;
}


This gives errors in the linking process, any ideas why? Thoughts/Solutions highly welcome.
The following linking errors occur:

Linking CXX executable myProject
Static_Libs/Itk/bin/libitksys.a(DynamicLoader.o): In function `itksys::DynamicLoader::OpenLibrary(char const*)':
DynamicLoader.cxx:(.text+0x15): undefined reference to `dlopen'
Static_Libs/Itk/bin/libitksys.a(DynamicLoader.o): In function `itksys::DynamicLoader::CloseLibrary(void*)':
DynamicLoader.cxx:(.text+0x2f): undefined reference to `dlclose'
Static_Libs/Itk/bin/libitksys.a(DynamicLoader.o): In function `itksys::DynamicLoader::GetSymbolAddress(void*, char const*)':
DynamicLoader.cxx:(.text+0x58): undefined reference to `dlsym'
Static_Libs/Itk/bin/libitksys.a(DynamicLoader.o): In function `itksys::DynamicLoader::LastError()':
DynamicLoader.cxx:(.text+0x6b): undefined reference to `dlerror'
collect2: ld returned 1 exit status
make[2]: *** [myProject] Error 1
make[1]: *** [CMakeFiles/myProject.dir/all] Error 2
make: *** [all] Error 2

Thanks in advance,
JaBa




More information about the Insight-users mailing list