[CMake] libxml2

Pau Garcia i Quiles pgquiles at elpauer.org
Fri Dec 14 05:59:11 EST 2007


Quoting Charlene Tsai <tsaicharlene at gmail.com>:

> Hi Pau Garcia i Quiles,
>
> Thanks for the suggestion. It works well on linux and Windows.
> However, it is still not happy with MinGW. To compile with MinGW, we
> need to have
>
> TARGET_LINK_LIBRARIES( my_lib ITKCommon ITKIO libxml2)
>
> and set ${LIBXML2_LIBRARIES} in CMake GUI to the directory where
> libxml2.{lib,a,dll} can be found.
>
> Instead, if we change the line to
>
> TARGET_LINK_LIBRARIES( my_lib ITKCommon ITKIO ${LIBXML2_LIBRARIES} )

Add the directory where the libraries are to the CMAKE_LIBRARY_PATH if  
using MinGW, ie:

IF(MINGW)
   SET( CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}  
C:\your\libxml2\libraries\dir )
ENDIF(MINGW)
FIND_PACKAGE(LibXml2)
etc

> the errors we get are something like
>
> C:\Isaac\Fars_Isaac\source_svn\bin\maciej_seg\libmaciejseg.a(xml_util.obj)(.text+0x3776):xml_util.cpp:
> undefined reference to `_imp__xmlFree'
> Any suggestions?
>
> Charlene
>
> On Dec 11, 2007 2:40 AM, Pau Garcia i Quiles <pgquiles at elpauer.org> wrote:
>>
>> Quoting Charlene Tsai <tsaicharlene at gmail.com>:
>>
>> > Hi,
>> >
>> > Could some please show me the proper way to handle libxml2 on Gentoo
>> > linux. In my CMakeLists.txt, if I include the following line it works
>> > on windows and some versions of linux:
>> >
>> >   TARGET_LINK_LIBRARIES( my_exe ITKCommon ITKIO libxml2)
>> >
>> > However, when trying to compile on Gentoo linux (using gcc 4.1.2) it
>> > complains about not being able to find libxml2.so for linking, unless
>> > I change it to:
>> >
>> > TARGET_LINK_LIBRARIES( my_exe ITKCommon ITKIO xml2)
>> >
>> > Any advice is appreciated.
>>
>> You should really read about how libraries and finders work in CMake.
>> There is a good amount of information in the wiki and the
>> Documentation section of the website.
>>
>> For libxml2, this is what you need:
>>
>> FIND_PACKAGE(LibXml2)
>> TARGET_LINK_LIBRARIES( my_exe ITKCommon ITKIO ${LIBXML2_LIBRARIES} )
>>
>> As you are using ITK, your CMakeLists.txt should look like this:
>>
>> FIND_PACKAGE(ITK REQUIRED)
>> IF(ITK_FOUND)
>>    INCLUDE(ITK_USE_FILE)
>> ENDIF(ITK_FOUND)
>> FIND_PACKAGE(LibXml2 REQUIRED)
>> ...
>> TARGET_LINK_LIBRARIES( my_exe ITKCommon ITKIO ${LIBXML2_LIBRARIES} )
>>
>> --
>> Pau Garcia i Quiles
>> http://www.elpauer.org
>> (Due to my workload, I may need 10 days to answer)
>>
>>
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)



More information about the CMake mailing list