错误LNK2019:外部符号

问题描述 投票:1回答:1

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

错误LNK2019:外部符号“public:virtual __cdecl elastix ELASTIX :: ::〜ELASTIX(void)”(?? 1ELASTIX @ elastix FALU @@@ XZ)未解决“public function:virtual void * __cdecl elastix eLASTIX: :: ::`标量删除析构函数'(unsigned int)“(?? _ @ elastix GELASTIX UEAAPEAXI @@@ Z)

我做了一些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.提前感谢

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;
}
c++ cmake itk cmake-gui elastix
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.