简体   繁体   中英

How to compile a library and then use it with ITK

I want to use TinyXml in my ITK project

Here is a typical CMakeLists.txt that I use when I am working exclusively on ITK

project( cl02johnsonhj )
cmake_minimum_required(VERSION 2.8)

find_package ( ITK REQUIRED )
include( ${USE_ITK_FILE} )

add_executable( IteratorTests IteratorTests.cxx )

target_link_libraries( IteratorTests ${ITK_LIBRARIES} )

So this project has IteratorTests.cxx

However, I want to use a xml parser for my project and our group currently uses TinyXML2. When I downloaded from github, it has two files namely tinyxml2.cpp and tinyxml2.h.

My question is how do I compile those two files(tinyxml2.cpp and tinyxml2.h) within my frame work, and use it as tinyxml library in my itk project? I am very new to cmake and how to make it work. I have been trying and so far no luck. Any help would be greatly appreciated.

Regards,

Probably, the simplest way is to replace

add_executable( IteratorTests IteratorTests.cxx )

with

add_executable( IteratorTests IteratorTests.cxx tinyxml2.cpp )

assuming that you have tinyxml2.cpp and tinyxml2.h right beside your own source files.

You also can make a separate library, but perhaps it's better to leave this exercise for the next time :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM