[ITK-users] Linker problems since Ubuntu 16.04 upgrade

soolijoo mattghall at gmail.com
Wed Sep 7 12:00:56 EDT 2016


Hi,

I've just upgraded to Ubuntu 16.04 from 14.04 and am having some strange
linker problems with my code.

Using the same CMakeLists.txt as previously the compiler is finding the ITK
headers but the build fails during the linking phase. This is happening even
for extremely simple, hello world type examples. For example the following
code:

#include "itkImage.h"
#include <iostream>

int main(int argc, char** argv){

    typedef itk::Image<unsigned short, 3> ImageType;

    ImageType::Pointer image = ImageType::New();

    std::cout << "Hey there, ITK!" << std::endl;

    return 0;

}


with this CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)

project(SimpleMutInfo)

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
if(ITKVtGlue_LOADED)
    find_package(VTK REQUIRED)
    include(${VTK_USE_FILE})
endif()

add_executable(SimpleMutInfo simpleMutInfo.cpp)

MESSAGE(${ITK_LIBRARIES})

MESSAGE(${CMAKE_INSTALL_PREFIX})
MESSAGE(${ITK_DIR})

if( "${ITK_VERSION_MAJOR}" LESS 4 )
    target_link_libraries(SimpleMutInfo ITKReview ${ITK_LIBRARIES})
else( "${ITK_VERSION_MAJOR}" LESS 4 )
    target_link_libraries(SimpleMutInfo ${ITK_LIBRARIES})
endif( "${ITK_VERSION_MAJOR}" LESS 4 )


completes the cmake apparently correctly:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/matt/CodingProjects/sandbox/mutInfo/itk/helloItk


but gives the following compiler error:
Scanning dependencies of target HelloItk
[ 50%] Building CXX object CMakeFiles/HelloItk.dir/helloItk.cpp.o
[100%] Linking CXX executable HelloItk
CMakeFiles/HelloItk.dir/helloItk.cpp.o: In function
`itk::MemoryAllocationError::MemoryAllocationError(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&, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)':
helloItk.cpp:(.text._ZN3itk21MemoryAllocationErrorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_S8_[_ZN3itk21MemoryAllocationErrorC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS8_S8_]+0x35):
undefined reference to
`itk::ExceptionObject::ExceptionObject(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&, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/HelloItk.dir/build.make:204: recipe for target 'HelloItk' failed
make[2]: *** [HelloItk] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/HelloItk.dir/all'
failed
make[1]: *** [CMakeFiles/HelloItk.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


I've confirmed that the i've installed all four ubuntu packages mentioned
here:
https://blog.kitware.com/itk-packages-in-linux-distributions/
(including the python bindings)

The itk libs seem to be in /usr/local/lib but for some reason the linker
isn't seeing them. 

Anyone got any ideas?








--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Linker-problems-since-Ubuntu-16-04-upgrade-tp7589172.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list