【问题标题】:How to compile a library and then use it with ITK如何编译一个库,然后将它与 ITK 一起使用
【发布时间】:2014-04-11 15:49:21
【问题描述】:

我想在我的 ITK 项目中使用 TinyXml

这是我专门从事 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} )

所以这个项目有 IteratorTests.cxx

但是,我想为我的项目使用 xml 解析器,而我们的团队目前使用 TinyXML2。 当我从 github 下载时,它有两个文件,即 tinyxml2.cpp 和 tinyxml2.h。

我的问题是如何在我的框架中编译这两个文件(tinyxml2.cpp 和 tinyxml2.h),并将其用作我的 itk 项目中的 tinyxml 库?我对 cmake 以及如何使其工作非常陌生。我一直在尝试,到目前为止还没有运气。任何帮助将不胜感激。

问候,

【问题讨论】:

    标签: c++ xml cmake itk


    【解决方案1】:

    大概,最简单的方法就是替换

    add_executable( IteratorTests IteratorTests.cxx )
    

    add_executable( IteratorTests IteratorTests.cxx tinyxml2.cpp )
    

    假设您在自己的源文件旁边有tinyxml2.cpptinyxml2.h

    你也可以创建一个单独的库,但也许下次练习会更好:)

    【讨论】:

      猜你喜欢
      • 2019-02-14
      • 2017-10-02
      • 2012-09-04
      • 2022-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多