[Insight-users] linking sequence of itk libraries

Luis Ibanez luis . ibanez at kitware . com
Fri, 12 Sep 2003 23:04:52 -0400


Hi Feng,

The order of libraries on the link line does matter on Unix.

If library A depends on library B,
                         then library A should go first on the link line.

You wouldn't have to worry about these details if you
where using CMake for configuring your project.

With CMake you can get the same link line by just writing the
following line in your  CMakeLists.txt file.

TARGET_LINK_LIBRARIES( myExecutable    ITKIO   pthread  )

CMake is smart enough to pull the rest of the dependencies.
For example it will know that

1) ITKIO depends on ITKCommon (so CMake will add ITKCommon to the link 
line).
2) ITKIO depends on itkpng, and itkpng depends on itkzlib (so CMake will 
add itkpng
                                                         and itkzlib to 
the link line).
and so on...

BTW if you are just building the Dicom parser example, you don't need
ITKFEM (which is a library for Finite Elements), nor ITKWrapper.
nor ITKStatistics. Just the three libraries in the TARGET_LINK
command shown above.

---

There are good reasons why CMake came into existance.

One of them is that it is more fun to do Image Processing than to
fiddle around with the order of libraries in a link list        :-)

Please use CMake,
and start enjoying ITK


Regards,


    Luis


----------------------
Feng Ma wrote:

> Hi,
>
>  I am working on to link ITK libraries to our existing code.  I 
> understand ITKCommon library should appear first. Does sequences of 
> other libraries matter?
>
>  I put it like this:
>
>  -lpthread -L/ITK/lib/InsightToolkit/ -lITKCommon -lITKDICOMParser 
> -lITKEXPAT -lITKFEM -ITKMetaIO -litknetlib -lITKNumerics -litkpng 
> -lITKStatistics -litksys -lITKVHDIO -lITKIO -lITKBasicFilters 
> -lITKAlgorithms -litkvnl -litkvnl_algo -litkzlib -lpthread 
> -L/ITKWrapper/lib -lITKWrapper
>
>  There is still a lot of undefined reference to itk objects.
>
>  Thanks a lot for helping out.
>
> -Feng
>
> _________________________________________________________________
> Send and receive larger attachments with Hotmail Extra Storage.   
> http://join . msn . com/?PAGE=features/es
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>