错误LNK2019:外部符号

时间:2014-12-09 20:35:40

标签: c++ cmake itk cmake-gui elastix

我在elastix处发出了新的声音并坚持开始。我试图用C ++编译一个verry基本程序,它将使用elastix库进行实例化。当我尝试编译程序时,我收到了链接器错误:

  

错误LNK2019:外部符号" public:virtual __cdecl elastix   ELASTIX :: :: ~ELASTIX(无效)" (?? 1ELASTIX @ elastix FALU @@@ XZ)   未解决的"公共函数:virtual void * __cdecl   elastix eLASTIX :: ::`标量删除析构函数'(unsigned int)" (??   _ @ elastix GELASTIX UEAAPEAXI @@@ Z)

我&#39;我做了一些googeling,发现它实际上是一个流行的链接器问题: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.提前感谢< / p>

CmakeList.txt     #使用外部项目的elastix代码的示例项目。     PROJECT(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;
}

1 个答案:

答案 0 :(得分:1)

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