MMzztx
MMzztx

Reputation: 233

How to solve 'undefined reference to'

I got some of this error when I compile on Ubuntu 16.04.1,

Linking CXX executable ../lib/Slicer-4.7/cli-modules/abcd
    /path/to/SimpleITK/SimpleITK-build/SimpleITK-build/lib/libSimpleITKBasicFilters1-0.11.so.1: undefined reference to `itk::ImageToImageFilter<itk::Image<int, 2u>, itk::Image<int, 2u> >::PushFrontInput(itk::DataObject const*)'

Does this undefined reference to means SimpleITK is not linked? Following is my Cmakelist:

cmake_minimum_required(VERSION 2.8.8)

#-----------------------------------------------------------------------------
set(MODULE_NAME "abcd")

#-----------------------------------------------------------------------------
set(MODULE_HOMEPAGE "${_EXT_HOMEPAGE}")
set(MODULE_CATEGORY "${_EXT_CATEGORY}")
set(MODULE_CONTRIBUTORS "abc")
set(MODULE_DESCRIPTION "abc" )
set(MODULE_ACKNOWLEDGEMENTS "${_EXT_ACKNOWLEDGEMENTS}")
set(MODULE_LICENSE_SHORT_DESCRIPTION "${MODULE_LICENSE_SHORT_DESCRIPTION}")
set(MODULE_MAJOR_VERSION "${_EXT_MAJOR_VERSION}")
set(MODULE_MINOR_VERSION "${_EXT_MINOR_VERSION}")
set(MODULE_PATCH_VERSION "${_EXT_PATCH_VERSION}")

# Configure XML description
configure_file(
  ${MODULE_NAME}.xml.in
  ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.xml
  @ONLY
  )

#-----------------------------------------------------------------------------
set(MODULE_INCLUDE_DIRECTORIES
  )

set(MODULE_SRCS
  )

set(MODULE_TARGET_LIBRARIES
  ${ITK_LIBRARIES} ${SimpleITK_LIBRARIES}
  )

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
  INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
  ADDITIONAL_SRCS ${MODULE_SRCS}
  )

#-----------------------------------------------------------------------------
if(BUILD_TESTING)
  add_subdirectory(Testing)
endif()

But as you can see, I do have link target library SimpleITK, and ITK, and that slicer module works fine in slicer 4.4 version but after slicer updates to 4.7, it does not work. Does anyone know how to fix that, or give me some clue? Any help appreciated.

Upvotes: 0

Views: 724

Answers (2)

blowekamp
blowekamp

Reputation: 1431

There may be a problem with the intra-dependencies in SimpleITK with the version Slicer is using Change:

set(MODULE_TARGET_LIBRARIES
  ${ITK_LIBRARIES} ${SimpleITK_LIBRARIES}
  )

to:

set(MODULE_TARGET_LIBRARIES
  ${SimpleITK_LIBRARIES} ${SimpleITK_LIBRARIES} ${ITK_LIBRARIES} 
  )

I believe the follow patch in SimpleITK will addressed the problem: https://github.com/SimpleITK/SimpleITK/commit/6fc22492ca1fd3ebb493160b7968c37a0a6f1986

Upvotes: 1

Dženan
Dženan

Reputation: 3395

Your problem seems to be with internal inconsistency of SimpleITK. Namely, some part of libSimpleITKBasicFilters1-0.11.so.1 expects PushFrontInput to be defined elsewhere, when it probably should have been exported from (or at least defined in) that library.

Edit: Slicer 4.7 is the current development version, and is hence unstable. Try 4.6.2 which is the latest stable release.

Upvotes: 1

Related Questions