[Insight-users] Link errors with static libs (shared fixes problems!)

Zachary Pincus zpincus at stanford.edu
Wed, 28 Apr 2004 12:02:54 -0700


[I'm posting this to the list for completeness sake, so the archives 
will have the full story]

Bill,

Thank you for your help in walking me through my misunderstandings... 
this makes perfect sense now.
I was able to get away with not telling CMake what ITK libraries my own 
libraries called only in the dynamic lib regime because then link order 
isn't as critical, and I was linking in the ITK libs at a later step in 
the game.

Thanks for your time; I am most appreciative.

Zach


On Apr 28, 2004, at 10:10 AM, William A. Hoffman wrote:

> You have to tell cmake which libraries your Cellxxx libraries use from 
> ITK.
> Use the TARGET_LINK_LIBRARIES command to do that.
> TARGET_LINK_LIBRARIES(CellExplorerCommon ITKCommon ??)
> Only the libraries directly used by CellExplorerCommon need to be 
> listed.
>
> -Bill
>
>
> At 12:56 PM 4/28/2004, Zachary Pincus wrote:
>> I'm definitely using cmake to build my project... the output below is 
>> the offending command when the "verbose makefile" option is set.
>>
>> Anyone have any thoughts as to what I should look at to try to figure 
>> out what's going on here?
>>
>> Thanks,
>>
>> Zach
>>
>>
>> On Apr 28, 2004, at 5:43 AM, William A. Hoffman wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>