[英]How to compile a library and then use it with ITK
I want to use TinyXml in my ITK project 我想在我的ITK项目中使用TinyXml
Here is a typical CMakeLists.txt that I use when I am working exclusively on ITK 这是我专门处理ITK时使用的典型CMakeLists.txt。
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 所以这个项目有IteratorTests.cxx
However, I want to use a xml parser for my project and our group currently uses TinyXML2. 但是,我想为我的项目使用xml解析器,并且我们的小组目前使用TinyXML2。 When I downloaded from github, it has two files namely tinyxml2.cpp and tinyxml2.h. 当我从github下载时,它有两个文件,即tinyxml2.cpp和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? 我的问题是如何在框架中编译这两个文件(tinyxml2.cpp和tinyxml2.h),并将其用作itk项目中的tinyxml库? I am very new to cmake and how to make it work. 我对cmake以及如何使其工作非常陌生。 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. 假设您在自己的源文件旁边有tinyxml2.cpp
和tinyxml2.h
。
You also can make a separate library, but perhaps it's better to leave this exercise for the next time :) 您也可以创建一个单独的库,但是最好下次进行此练习:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.