SimVascular / svSolver

Separate repository for svSolver
16 stars 23 forks source link

Recompile with -fPIE #124

Closed magadator closed 1 year ago

magadator commented 1 year ago

I was trying to compile the code on Ubuntu 20.04.6 LTS with gcc and g++ version 9 (tried with 7.5 as well). The code fails to compile at [ 43%] Building CXX object FlowSolvers/ThreeDSolver/svPost/CMakeFiles/svpost.dir/post_solver.cxx.o [ 44%] Linking CXX executable ../../../bin/svpost /usr/bin/ld: /home/local/AD/magadator/SimVascular/solver/svSolver/Externals-build/sv_externals/bin/gnu/7.5/x64/vtk-8.1.1/lib/libvtkCommonCore-8.1.a(vtkDataArray.cxx.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE

I tried adding the "-fPIE" flag in almost all CFLAGS, CXXFLAGS, and EXE_LINKER_FLAGS but without any success. Is there any workaround to compile the code?

ktbolt commented 1 year ago

@magadator The error means that the VTK externals where not compiled with the -fPIE flag. But I do think the externals were compiled with that flag so maybe this is due to the differences in gcc versions.

The workaround is to use a local version of VTK when building svSolver.

magadator commented 1 year ago

I installed VTK-9.2.6 and the installation process of sv went slightly ahead and hits this error:

46%] Building CXX object FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/cmd.cxx.o [ 46%] Building CXX object FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/displacements.cxx.o [ 47%] Building CXX object FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/helpers.cxx.o /home/local/AD/magadator/SimVascular/solver/svSolver/Code/FlowSolvers/ThreeDSolver/svPre/helpers.cxx: In function ‘int VtkUtils_GetAllPolys(vtkPolyData, int, vtkIdType)’: /home/local/AD/magadator/SimVascular/solver/svSolver/Code/FlowSolvers/ThreeDSolver/svPre/helpers.cxx:1927:40: error: cannot bind non-const lvalue reference of type ‘const vtkIdType&’ {aka ‘const long l\ ong int&’} to an rvalue of type ‘const vtkIdType’ {aka ‘const long long int’} 1927 | while ( pdPgns->GetNextCell( npts, pts ) ) { | ^~~ In file included from /usr/local/include/vtk-9.2/vtkPolyData.h:68, from /home/local/AD/magadator/SimVascular/solver/svSolver/Code/FlowSolvers/ThreeDSolver/svPre/cmd.h:57, from /home/local/AD/magadator/SimVascular/solver/svSolver/Code/FlowSolvers/ThreeDSolver/svPre/helpers.cxx:38: /usr/local/include/vtk-9.2/vtkCellArray.h:1525:73: note: initializing argument 2 of ‘int vtkCellArray::GetNextCell(vtkIdType&, const vtkIdType&)’ 1525 | inline int vtkCellArray::GetNextCell(vtkIdType& npts, vtkIdType const& pts) VTK_SIZEHINT(pts, npts) | ~~~~^ make[5]: ** [FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/build.make:89: FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/helpers.cxx.o] Error 1 make[4]: [CMakeFiles/Makefile2:609: FlowSolvers/ThreeDSolver/svPre/CMakeFiles/svpre.dir/all] Error 2 make[3]: [Makefile:130: all] Error 2 make[2]: [CMakeFiles/svSolver.dir/build.make:111: svSolver-prefix/src/svSolver-stamp/svSolver-build] Error 2 make[1]: [CMakeFiles/Makefile2:73: CMakeFiles/svSolver.dir/all] Error 2 make: [Makefile:84: all] Error 2

Is there any particular version of vtk that sv likes?

magadator commented 1 year ago

It compiles with vtk 8.2