Hello everyone,
I created an MVC in a python notebook and then I want to translate it to C++.
In order to do that, I followed the building instructions and I successfully compiled simpeITK. I am using CLion as an IDE.
I included the headers and I linked some static libraries but, I am still getting undefined references. Please, see below my CMake file.
cmake_minimum_required(VERSION 3.17)
project(untitled1)
set(CMAKE_CXX_STANDARD 20)
include_directories( /home/kasco/SimpleITK-build/include/SimpleITK-2.1 )
add_executable(untitled1 main.cpp test.cpp)
target_link_libraries (untitled1
/home/kasco/SimpleITK-build/lib/libSimpleITKIO-2.1.a
/home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a
/home/kasco/SimpleITK-build/lib/libSimpleITKBasicFilters0-2.1.a
/home/kasco/SimpleITK-build/lib/libSimpleITKBasicFilters1-2.1.a)
I also tried including all the .a files but it still throwing errors.
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o): in function `_GLOBAL__sub_I_sitkProcessObject.cxx':
sitkProcessObject.cxx:(.text.startup+0x31): undefined reference to `itk::AnyEvent::~AnyEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0x4b): undefined reference to `itk::AbortEvent::~AbortEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0x65): undefined reference to `itk::DeleteEvent::~DeleteEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0x7f): undefined reference to `itk::EndEvent::~EndEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0x99): undefined reference to `itk::IterationEvent::~IterationEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0xb3): undefined reference to `itk::ProgressEvent::~ProgressEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0xcd): undefined reference to `itk::StartEvent::~StartEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0xe7): undefined reference to `itk::UserEvent::~UserEvent()'
/usr/bin/ld: sitkProcessObject.cxx:(.text.startup+0x101): undefined reference to `itk::MultiResolutionIterationEvent::~MultiResolutionIterationEvent()'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x10): undefined reference to `typeinfo for itk::Command'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x40): undefined reference to `itk::LightObject::Delete()'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x50): undefined reference to `itk::Object::Register() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x58): undefined reference to `itk::Object::UnRegister() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x68): undefined reference to `itk::Object::SetReferenceCount(int)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x80): undefined reference to `itk::Object::PrintSelf(std::ostream&, itk::Indent) const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x88): undefined reference to `itk::LightObject::PrintHeader(std::ostream&, itk::Indent) const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x90): undefined reference to `itk::LightObject::PrintTrailer(std::ostream&, itk::Indent) const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0x98): undefined reference to `itk::LightObject::InternalClone() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xa0): undefined reference to `itk::Object::DebugOn() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xa8): undefined reference to `itk::Object::DebugOff() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xb0): undefined reference to `itk::Object::GetMTime() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xb8): undefined reference to `itk::Object::GetTimeStamp() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xc0): undefined reference to `itk::Object::Modified() const'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel.ro+0xd8): undefined reference to `itk::Object::SetTimeStamp(itk::TimeStamp const&)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x0): undefined reference to `vtable for itk::MultiResolutionIterationEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x8): undefined reference to `vtable for itk::UserEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x10): undefined reference to `vtable for itk::StartEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x18): undefined reference to `vtable for itk::ProgressEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x20): undefined reference to `vtable for itk::IterationEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x28): undefined reference to `vtable for itk::EndEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x30): undefined reference to `vtable for itk::DeleteEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x38): undefined reference to `vtable for itk::AbortEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkProcessObject.cxx.o):(.data.rel+0x40): undefined reference to `vtable for itk::AnyEvent'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkExceptionObject.cxx.o): in function `itk::simple::GenericException::GenericException(itk::simple::GenericException const&)':
sitkExceptionObject.cxx:(.text+0x1b4): undefined reference to `itk::ExceptionObject::ExceptionObject(itk::ExceptionObject const&)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkExceptionObject.cxx.o): in function `itk::simple::GenericException::GenericException(char const*, unsigned int)':
sitkExceptionObject.cxx:(.text+0x226): undefined reference to `itk::ExceptionObject::ExceptionObject(char const*, unsigned int, char const*, char const*)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkExceptionObject.cxx.o): in function `itk::simple::GenericException::GenericException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)':
sitkExceptionObject.cxx:(.text+0x357): undefined reference to `itk::ExceptionObject::ExceptionObject(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkExceptionObject.cxx.o): in function `itk::simple::GenericException::GenericException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
sitkExceptionObject.cxx:(.text+0x56a): undefined reference to `itk::ExceptionObject::ExceptionObject(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkObjectOwnedBase.cxx.o): in function `itk::simple::ObjectOwnedBase::SetOwnedByObjects(bool)':
sitkObjectOwnedBase.cxx:(.text+0x4e5): undefined reference to `itk::OutputWindowDisplayWarningText(char const*)'
/usr/bin/ld: /home/kasco/SimpleITK-build/lib/libSimpleITKCommon-2.1.a(sitkObjectOwnedBase.cxx.o): in function `itk::simple::ObjectOwnedBase::ExecuteCallbacks()':
sitkObjectOwnedBase.cxx:(.text+0x9e8): undefined reference to `itk::OutputWindowDisplayWarningText(char const*)'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/untitled1.dir/build.make:167: untitled1] Error 1
make[2]: *** [CMakeFiles/Makefile2:96: CMakeFiles/untitled1.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/untitled1.dir/rule] Error 2
make: *** [Makefile:138: untitled1] Error 2
I intend to embed the IO and the registration libraries into my software. I want to link the minimum libraries as possible.
Am I missing something in the CMake file?
Thanks