Slicer CLI module compilation error: undefined reference to `itk::GeometryUtilities

Hellow friends,

I’m very much a beginner in the 3DSlicer development world. I’m struggling with a compilation problem.
I created a CLI module through Slicer “Extension Manager” and started to change it according to my goals.
I then go to Cmake-gui to generate and configure. And sounds that everything went well except for two warnings:

CMake Warning (dev) at /home/leonardo/General_Sources/Slicer/CMake/SlicerMacroExtractRepositoryInfo.cmake:95 (message):
  Skipping repository info extraction: directory
  [/home/leonardo/Desktop/Modulos-Source/Modulos_to_Slicer/CSIM] is not a
  GIT, SVN or CVS checkout
Call Stack (most recent call first):
  /home/leonardo/General_Sources/Slicer/Extensions/CMake/SlicerExtensionPackageAndUploadTarget.cmake:122 (SlicerMacroExtractRepositoryInfo)
  /home/leonardo/General_Sources/Slicer/CMake/SlicerExtensionCPack.cmake:219 (include)
  CMakeLists.txt:27 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.


Furthermore **in the QT compilation step** it happen as follows:

1) When I creat and execute my CLI module **directly** (**Without Extension Wizard**):

I use the following **CMakeLists.txt**:

#####################################
#-----------------------------------------------------------------------------
project(TextureProcessingV8)

cmake_minimum_required( VERSION 2.6 )

set(MODULE_NAME TextureProcessing)

if(NOT Slicer_SOURCE_DIR)
  find_package(Slicer REQUIRED)
  include(${Slicer_USE_FILE})
endif()

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  #LOGO_HEADER ${Slicer_SOURCE_DIR}/Resources/ITKLogo.h
  ADDITIONAL_SRCS
    Plot/HistogramPlot.cxx
    Percents/PercentileCalc.cxx
    Features/HistoFeat.cxx
    CoocurrenceFeat/CoocurrenceFeat.cxx
    ShapeFeatures/ShapeFeat.cxx
    RunLengthFeat/RunLengthFeat.cxx
    Normalization/Normalize.cxx
    Gradient/GradientFeat.cxx		 	

  TARGET_LIBRARIES ${ITK_LIBRARIES}
  )

#add_subdirectory(Texture)

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

########################################################

**No ERROR Occurred AT ALL**

2) When I insert the same CLI source code inside the **EXTENSION WIZARD** Pre-built files:

I use the following CMakeLists.txt for the **MODULE**
##############################################


#-----------------------------------------------------------------------------
set(MODULE_NAME TextureProcessing)

#-----------------------------------------------------------------------------

#
# SlicerExecutionModel
#
find_package(SlicerExecutionModel REQUIRED)
include(${SlicerExecutionModel_USE_FILE})

#
# ITK
#
set(${PROJECT_NAME}_ITK_COMPONENTS
  ITKIOImageBase
  ITKSmoothing
  )
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
include(${ITK_USE_FILE})

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

set(MODULE_SRCS
  )

set(MODULE_TARGET_LIBRARIES
  ${ITK_LIBRARIES}
  )

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
  INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
  ADDITIONAL_SRCS ${MODULE_SRCS}
Plot/HistogramPlot.cxx
    Percents/PercentileCalc.cxx
    Features/HistoFeat.cxx
    CoocurrenceFeat/CoocurrenceFeat.cxx
    ShapeFeatures/ShapeFeat.cxx
    RunLengthFeat/RunLengthFeat.cxx
    Normalization/Normalize.cxx
    Gradient/GradientFeat.cxx
  )

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

#############################################################

And the following **CMakeLists.txt for the EXTENSION**:

The following **Errors OCCUR**:

**error: undefined reference to `itk::GeometryUtilities::HyperSphereRadiusFromVolume(int, double)'**
**/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:372: **

**error: undefined reference to `itk::GeometryUtilities::HyperSpherePerimeter(int, double)'**
**/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:373: **

**error: undefined reference to `itk::GeometryUtilities::HyperSphereRadiusFromVolume(int, double)'**
**/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:372: **

**error: undefined reference to `itk::GeometryUtilities::HyperSpherePerimeter(int, double)'**
**/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:373:'** 

I really can't find the solution.
I appreciate any contributions!!!!

This is just a warning that CMake cannot automatically detect your source code repository URL. You can safely ignore it.

To fix the undefined reference error mentioned in the title, make sure you have included the ITK header file where GeometryUtilities is declared in.

Auh… Thank you very much for the feedback.
Unfortunately I didn’t finish my question before submitting the post. I’m
sorry.

But the final part of the problem I’m struggling is error:
‘Undefined reference’

I’ll post the complete error log soon as I get the chance.

Thanks a lot for now.

@lassoan, this is the complete version of my question. Would love to hear any help.

I’m very much a beginner in the 3DSlicer development world. I’m struggling with a compilation problem.
I created a CLI module through Slicer “Extension Manager” and started to change it according to my goals.
I then go to Cmake-gui to generate and configure. And sounds that everything went well except for two warnings:

CMake Warning (dev) at /home/leonardo/General_Sources/Slicer/CMake/SlicerMacroExtractRepositoryInfo.cmake:95 (message):
  Skipping repository info extraction: directory
  [/home/leonardo/Desktop/Modulos-Source/Modulos_to_Slicer/CSIM] is not a
  GIT, SVN or CVS checkout
Call Stack (most recent call first):
  /home/leonardo/General_Sources/Slicer/Extensions/CMake/SlicerExtensionPackageAndUploadTarget.cmake:122 (SlicerMacroExtractRepositoryInfo)
  /home/leonardo/General_Sources/Slicer/CMake/SlicerExtensionCPack.cmake:219 (include)
  CMakeLists.txt:27 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

Furthermore in the QT compilation step it happen as follows:

  1. When I creat and execute my CLI module directly (Without Extension Wizard):

I use the following CMakeLists.txt:

#####################################
#-----------------------------------------------------------------------------
project(TextureProcessingV8)

cmake_minimum_required( VERSION 2.6 )

set(MODULE_NAME TextureProcessing)

if(NOT Slicer_SOURCE_DIR)
  find_package(Slicer REQUIRED)
  include(${Slicer_USE_FILE})
endif()

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  #LOGO_HEADER ${Slicer_SOURCE_DIR}/Resources/ITKLogo.h
  ADDITIONAL_SRCS
    Plot/HistogramPlot.cxx
    Percents/PercentileCalc.cxx
    Features/HistoFeat.cxx
    CoocurrenceFeat/CoocurrenceFeat.cxx
    ShapeFeatures/ShapeFeat.cxx
    RunLengthFeat/RunLengthFeat.cxx
    Normalization/Normalize.cxx
    Gradient/GradientFeat.cxx		 	

  TARGET_LIBRARIES ${ITK_LIBRARIES}
  )

#add_subdirectory(Texture)

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

########################################################

No ERROR Occurred AT ALL

  1. When I insert the same CLI source code inside the EXTENSION WIZARD Pre-built files:

I use the following CMakeLists.txt for the MODULE

##############################################


#-----------------------------------------------------------------------------
set(MODULE_NAME TextureProcessing)

#-----------------------------------------------------------------------------

#
# SlicerExecutionModel
#
find_package(SlicerExecutionModel REQUIRED)
include(${SlicerExecutionModel_USE_FILE})

#
# ITK
#
set(${PROJECT_NAME}_ITK_COMPONENTS
  ITKIOImageBase
  ITKSmoothing
  )
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
include(${ITK_USE_FILE})

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

set(MODULE_SRCS
  )

set(MODULE_TARGET_LIBRARIES
  ${ITK_LIBRARIES}
  )

#-----------------------------------------------------------------------------
SEMMacroBuildCLI(
  NAME ${MODULE_NAME}
  TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
  INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
  ADDITIONAL_SRCS ${MODULE_SRCS}
Plot/HistogramPlot.cxx
    Percents/PercentileCalc.cxx
    Features/HistoFeat.cxx
    CoocurrenceFeat/CoocurrenceFeat.cxx
    ShapeFeatures/ShapeFeat.cxx
    RunLengthFeat/RunLengthFeat.cxx
    Normalization/Normalize.cxx
    Gradient/GradientFeat.cxx
  )

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

#############################################################

And the following CMakeLists.txt for the EXTENSION:

cmake_minimum_required(VERSION 3.5)

project(TextureAnalysis)

#-----------------------------------------------------------------------------
# Extension meta-information
set(EXTENSION_HOMEPAGE "http://slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/CSIM")
set(EXTENSION_CATEGORY "Examples")
set(EXTENSION_CONTRIBUTORS "John Doe (AnyWare Corp.)")
set(EXTENSION_DESCRIPTION "This is an example of a simple extension")
set(EXTENSION_ICONURL "http://www.example.com/Slicer/Extensions/CSIM.png")
set(EXTENSION_SCREENSHOTURLS "http://www.example.com/Slicer/Extensions/CSIM/Screenshots/1.png")
set(EXTENSION_DEPENDS "NA") # Specified as a space separated string, a list or 'NA' if any

#-----------------------------------------------------------------------------
# Extension dependencies
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})

#-----------------------------------------------------------------------------
# Extension modules
add_subdirectory(TextureProcessing)
## NEXT_MODULE

#-----------------------------------------------------------------------------
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})

The following Errors OCCURED:

error: undefined reference to `itk::GeometryUtilities::HyperSphereRadiusFromVolume(int, double)’
/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:372:

error: undefined reference to `itk::GeometryUtilities::HyperSpherePerimeter(int, double)’
/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:373:

error: undefined reference to `itk::GeometryUtilities::HyperSphereRadiusFromVolume(int, double)’
/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:372:

error: undefined reference to `itk::GeometryUtilities::HyperSpherePerimeter(int, double)’
/usr/local/Slicer/ITKv4/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx:373:’

I really can’t find the solution.
I appreciate any contributions!!!

Please upload your extension to github and post the link here so that I can have a look. Thanks!

Ok. Thank you very much. I’ll take a time… once I’m also starting with git and everything… But I’ll do it right away.
Thank you!

Dr. Lasso,

I just added you to my github project. Hope you can check it out!

Thank you very much!

The solution was to adjust the CMakeLists.txt:

  • add ITKLabelMap to ${PROJECT_NAME}_ITK_COMPONENTS
  • add ${CMAKE_CURRENT_SOURCE_DIR} to MODULE_INCLUDE_DIRECTORIES
  • add ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES} to target_link_libraries(${CLP}Test ${CLP}Lib ...) (probably old version of Extension Wizard was used, that’s why it was missing)

See details here:
https://github.com/MachadoLF/CLI-Module---Texture-Feature-Extractor/pull/1

Thank you very much, Dr. Lasso.

It completely fixed my problems!!!

I tested change by change and saw that the first one (add ITKLabelMap to ${PROJECT_NAME}_ITK_COMPONENTS) had already solved ALL my issues without even doing the additional ones.

In this case, is it necessary to make the additional changes you mentioned? Or is it only something like good programming practices?

What do you think?

Thanks a lot for your feedback!!!

Most often, header files are in a single directory, as when you have files that are not tightly linked, you compile them as separate libraries.

In some cases, you use relative paths, but then the usually you add the base folder to the list of include directories and you define paths relative to that (and never use ./ or ../ in the #include directive).

Your last comment is related to this change?

Yes. It adds the source code top-level directory to the include paths. So, if you need to refer to a header file then you can always do that relative to this top-level directory and you don’t need to reach it by prepending ../../ to the header file name.

Ok! I got it! Thank you very much. Everything worked out nice and smoothly. And thanks for the tips with programming.

Thanks again!

Machado, L.

A post was merged into an existing topic: Error: failed to read input surface\ compiled CLI module