gpt4 book ai didi

c++ - 错误 LNK2019 : external symbol

转载 作者:太空宇宙 更新时间:2023-11-04 11:23:43 24 4
gpt4 key购买 nike

我很新 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com