[Insight-users] About linking when using -lz

Luis Ibanez luis.ibanez at kitware.com
Tue Mar 24 11:32:18 EDT 2009


Hi 李健

Modify the CMake line:

TARGET_LINK_LIBRARIES(testImage ${ITK_LIBRARIES} ${IMAGE_LIBRARY})

to make it:

TARGET_LINK_LIBRARIES(testImage ${ITK_LIBRARIES} ${IMAGE_LIBRARY} z )

That should do the trick, if your library "libz.a" is already in the
library path.


    Regards,


        Luis


----------------
李健 wrote:
> Dear all:
>  
>  When I use itk in Linux, I need to link an executable to a 
> non-itk library. It seems that I should use "-lz" in my link. But I 
> don't know how to use this option in CMakeLists.txt.  Can anyone tell me 
> how to use "-lz" in CMakeLists.txt?
>  
> Thanks a lot.
>  
>  The following is my CMakeLists.txt:
>  
>  
> cmake_minimum_required(VERSION 2.6)
> PROJECT(testImage)
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
>   INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
>   MESSAGE(FATAL_ERROR
>           "ITK not found. Please set ITK_DIR.")
> ENDIF(ITK_FOUND)
> ADD_EXECUTABLE(testImage testImage.cpp)
> find_library(IMAGE_LIBRARY NAMES image PATHS /home/zzz/lib)
> TARGET_LINK_LIBRARIES(testImage ${ITK_LIBRARIES} ${IMAGE_LIBRARY})
>  
>  
> 
> ------------------------------------------------------------------------
> 立刻下载 MSN 保护盾,保障 MSN 安全稳定! 现在就下载! 
> <http://im.live.cn/safe/>
> 
> 
> ------------------------------------------------------------------------
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list