1

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;
}
Community
  • 1
  • 1
jorne
  • 894
  • 2
  • 11
  • 23
  • Likely the elastix library isn't linked because it either is not specified in the linker flags, or is specified incorrectly. If you'd use GNU make I'd suggest you to run something like `make VERBOSE=1` to see actual linker flags, but since you're likely using `nmake`, than perhaps this [SO question](http://stackoverflow.com/questions/23560590/verbose-nmake-makefiles-using-cmake) could help you to investigate what the actual flags are. – user3159253 Dec 09 '14 at 20:49
  • I use the cmake-gui, I set the path manualy and reconfigured afterwards. – jorne Dec 09 '14 at 21:27

1 Answers1

1

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

jorne
  • 894
  • 2
  • 11
  • 23