[Insight-users] Link errors with static libs (shared fixes
problems!)
William A. Hoffman
billlist at nycap.rr.com
Wed, 28 Apr 2004 08:43:46 -0400
With static linking the order of the libraries is important because
it is a single pass operation. If you use CMake to build the project,
the order is done correctly automatically.
You may want to consider using cmake to build your application.
-Bill
At 04:39 AM 4/28/2004, Zachary Pincus wrote:
>Hello, and I promise that this is my last plaintive request for tonight...
>
>After finally getting ITK updated from the CVS and compiled, I've run into strange linker errors when rebuilding my applications. Basically, they're complaining that certain symbols are undefined; however I can check the libs and verify that they're around.
>
>Here's the really strange part: this only occurs when I'm using the static libraries. If I rebuild ITK with the same settings but with "build shared libs" set to "ON", and then rebuild my project, everything works just fine. I'm using OS X 10.3.3 with gcc 3.3. "Explicit Instantiations" are turned off.
>
>Here is the specific error (the Cellxxxx libraries are my own):
>
>Building executable /.../ImageExtractionAndPCATester...
>c++ -ftemplate-depth-50 -no-cpp-precomp -Wno-long-double -fmessage-length=0 -fPIC ./ImageExtractionAndPCATester.o [link directories snipped] -lITKCommon -lITKIO -lCellExplorerCommon -lCellExtractor -lCellFeatures -lITKCommon -litkvnl_inst -litkvnl_algo -litkvnl -litkvcl -litknetlib -lm -litksys -lpthread -litkpng -litktiff -litkjpeg -lm -lITKMetaIO -litkzlib -lITKDICOMParser -lITKEXPAT
>ld: Undefined symbols:
>itk::ImageIOBase::SetNumberOfDimensions(unsigned)
>itk::ImageIOFactory::CreateImageIO(char const*, itk::ImageIOFactory::FileModeType)
>itk::operator<<(std::basic_ostream<char, std::char_traits<char> >&, itk::ImageIORegion const&)
>itk::ImageIOBase::GetImageSizeInBytes() const
>vtable for itk::ImageIORegion
>
>Why would these symbols be undefined? I can find them in the linked-in libraries with nm well enough, and other symbols from the IO and Common (and other) libraries are found easily enough. Can anyone provide any clues as to where to look to deal with this? Why is this magically fixed with the dynamic libs? As usual, the linker is sufficiently mysterious to me that I'm not much help.
>
>Thanks,
>
>Zach Pincus
>
>Department of Biochemistry and Program in Biomedical Informatics
>Stanford University School of Medicine
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users