Skip to content

Commit a2d14f6

Browse files
hjmjohnsonclaude
andcommitted
COMP: Enable position-independent code for src/ executables
Modern GCC on Ubuntu 22.04+ defaults to building PIE (position- independent executables). When the ITK shared libraries are compiled with -fPIC but the executables are not built with -fPIE, the typeinfo for itk::ExceptionObject cannot be resolved at link time: undefined reference to typeinfo for itk::ExceptionObject warning: creating DT_TEXTREL in a PIE Setting CMAKE_POSITION_INDEPENDENT_CODE=ON in src/CMakeLists.txt ensures compatible code generation between the executables and the ITK shared libraries they link against. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9dcea5e commit a2d14f6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
include_directories("${VariationalRegistration_SOURCE_DIR}/include")
22
include_directories("${VariationalRegistration_SOURCE_DIR}/src")
33

4+
# Modern GCC on Ubuntu 22.04+ defaults to PIE executables. Ensure
5+
# position-independent code so typeinfo lookups for ITK exceptions
6+
# resolve correctly against the -fPIC shared libraries.
7+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8+
49
# Test if ITK is built with FFTW. FFTWD is recommended and required for the
510
# tests with elastic or curvature regularisation to pass.
611
if(ITK_USE_FFTWF AND NOT ITK_USE_FFTWD)

0 commit comments

Comments
 (0)