c++ - 错误 LNK2019 : external symbol

标签 c++ cmake itk cmake-gui elastix

我很新 elastix并停留在最开始。我正在尝试用 C++ 编译一个非常基本的程序,它将使用 elastix 库进行实例化。当我尝试编译程序时,出现链接器错误:

Error LNK2019: external symbol "public: virtual __cdecl elastix ELASTIX :: :: ~ ELASTIX (void)" (?? 1ELASTIX @ elastix FALU@@@XZ) unresolved referred to in the "public function: virtual void * __cdecl elastix eLASTIX :: :: `scalar deleting destructor '(unsigned int)" (?? _ @ elastix GELASTIX UEAAPEAXI@@@Z)

我做了一些谷歌搜索,发现它实际上是一个流行的链接器问题:see this topic and this one and this particular elastix mail chain .我尝试使用这些链接修复它但没有成功。我想知道你们是否可以帮助我。下面你可以找到我的源文件(CMakeList.txt 和 C++ 代码)和一些附加信息:我运行 Windows 7,Cmake 版本是 3.0.2,ITK 版本是 4.6,elastix 版本是 4.7 和 Microsoft VS 2008。提前致谢

CmakeList.txt # 使用来自外部项目的 elastix 代码的示例项目。 项目( elxExternalProject )

CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )

# Find TIK
FIND_PACKAGE( ITK REQUIRED )
INCLUDE( ${ITK_USE_FILE} )

# find elastix
SET( ELASTIX_BINARY_DIR "" CACHE PATH "Path to elastix binary folder" )
SET( ELASTIX_USE_FILE ${ELASTIX_BINARY_DIR}/UseElastix.cmake )
IF( EXISTS ${ELASTIX_USE_FILE} )
 MESSAGE( STATUS "Including Elastix settings." )
 INCLUDE( ${ELASTIX_USE_FILE} )
ENDIF()

# Build a small test executable (this test is basically the same as
# the one found in the <elastix-dir>/src/Testing dir.
ADD_EXECUTABLE( elxtimertest itkTimerTest.cxx )

# Link to some libraries
TARGET_LINK_LIBRARIES( elxtimertest
  ITKCommon elxCommon elastix )

C++代码

#include "elastixlib.h"
using namespace elastix;

int main( int argc, char *argv[] )
{

    ELASTIX* el = new ELASTIX();
    std::cerr << "elastix created" << std::endl;

    delete el;
    return 0;
}

最佳答案

所以我解决了。我回溯了整个事情,似乎 CMake 没有应用我在 GUI 中所做的更改。所以我手动更改了 CMakeLists。之后,像魅力一样工作

关于c++ - 错误 LNK2019 : external symbol,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27388354/

相关文章:

c++ - 如何使 for 循环中的变量大于原来的变量

c++ - C++ main函数中的继承初始化

c++ - 将 cmake 的 target_compile_features 与 biicode 结合使用

python - 如何对使用 SimpleITK 读取的 DICOM 图像进行直方图均衡化

c++ - 将 ITK(insight Toolkit)结果写入本地缓冲区

c++ - 存储需要精确匹配和最接近匹配的值的最佳结构

c++ - 在没有邻接表或邻接矩阵的情况下 boost 图形设计

ios - 如何为 iOS 构建 Tesseract 4.0.0 版本?

c++ - CMAKE - 调试/交叉构建?

python - 将 CMakeLists.txt、boost-python 与 python setuptools 相结合