相关疑难解决方法(0)

如何使用CMake链接多个库

我有一些与DCMTK有关的代码.如果我从命令行使用g ++,我可以成功构建并运行它.这是代码:

#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
   OFString patientsName;
   if (fileformat.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good())
   {
      cout << "Patient's Name: " << patientsName << endl;
   } else
     cerr << "Error: cannot access Patient's Name!" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是构建命令:

g++ testeapp.cxx -DHAVE_CONFIG_H -I/path_to_dcmtk/include -L/path_to_dcmtk/lib -pthread -ldcmdata -lz -loflog -lofstd -o main
Run Code Online (Sandbox Code Playgroud)

我想制作一个CMakeLists.txt来在Kdevelop中构建它.这就是我目前拥有的:

    # Configure toplevel …
Run Code Online (Sandbox Code Playgroud)

c++ cmake dicom

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

cmake ×1

dicom ×1