Error LNK2019: external symbol

416 views Asked by At

I'm verry new at elastix and stuck at the verry beginning. I'm trying to compile a verry basic program in C++ that will make an instantiation of the using elastix library. When I tried to compile the program, I got a linker error:

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)

I' ve done some googeling and found that it is infact a popular linker problem: see this topic and this one and this particular elastix mail chain. I tried to fix it using these links but without succes. I'm wondering if you guys/girls could help me out. below you can find my source files (CMakeList.txt and C++ code) and some additional information: I run windows 7, Cmake version is 3.0.2, ITK version is 4.6, elastix version is 4.7 and Microsoft VS 2008. Thanks in advance

CmakeList.txt # Example project for using elastix code from external projects. 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++ code

#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

There are 1 answers

0
jorne On

So i got it solved. I backtracked the whole thing and it seemed that CMake didn't apply my changes i made in the GUI. So i chaged the CMakeLists by hand. Afterwards, worked like a charm