DLR-AMR / t8code

Parallel algorithms and data structures for tree-based adaptive mesh refinement (AMR) with arbitrary element shapes.

Home Page:https://dlr-amr.github.io/t8code/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling examples using the CMake build system while compiling t8code as a static archive

maelk3 opened this issue · comments

When compiling t8code as a static archive with the CMake build system, compiling the examples fail. Steps to reproduce:

cmake ../../t8code/ -DCMAKE_BUILD_TYPE=Release          \
                    -DT8CODE_BUILD_EXAMPLES=ON          \
                    -DT8CODE_BUILD_AS_SHARED_LIBRARY=OFF
make VERBOSE=ON

I get the following error:

/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/gcc-11.3.0-avy3yt67apn6ntfapginc4al4misogxc/bin/g++ -fPIC -Wall -O3 -DNDEBUG -Wl,-rpath,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/gcc-11.3.0-avy3yt67apn6ntfapginc4al4misogxc/lib/gcc/x86_64-pc-linux-gnu/11.3.0 -Wl,-rpath,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/gcc-11.3.0-avy3yt67apn6ntfapginc4al4misogxc/lib64 -Wl,-rpath -Wl,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-11.3.0/openmpi-4.1.4-et3mvomberawonlbtmlhmgizdbt7kpyo/lib -Wl,-rpath -Wl,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/hwloc-2.7.1-w326eq6c7fwh4zfstu6ay6tvo3kjb74p/lib -Wl,-rpath -Wl,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/libevent-2.1.12-cbwrmcg6lku6hmautq4el6w3lwtbgh2l/lib -Wl,-rpath -Wl,/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/pmix-4.1.2-hpy3nk773gbvbb2adlziutsoclcn7npw/lib -L/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/hwloc-2.7.1-w326eq6c7fwh4zfstu6ay6tvo3kjb74p/lib -L/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/libevent-2.1.12-cbwrmcg6lku6hmautq4el6w3lwtbgh2l/lib -L/tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/pmix-4.1.2-hpy3nk773gbvbb2adlziutsoclcn7npw/lib -pthread -shared -Wl,-soname,libt8example.so -o libt8example.so CMakeFiles/t8example.dir/common/t8_example_common.cxx.o CMakeFiles/t8example.dir/common/t8_example_common_functions.cxx.o  -Wl,-rpath,/localdata1/kare_ma/builds/build_Release/p4est:/localdata1/kare_ma/builds/build_Release/sc: ../src/libt8.a ../p4est/libp4est.so.3.0.0 ../sc/libsc.so.2.0.0 /tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-9.4.0/zlib-1.2.12-ilkcdjtcxbcazc2nrczn6j2fwduunxhy/lib/libz.so -lm /tools/modulesystem/spack-22.2/opt/spack/linux-ubuntu20.04-x86_64_v3/gcc-11.3.0/openmpi-4.1.4-et3mvomberawonlbtmlhmgizdbt7kpyo/lib/libmpi.so 
/usr/bin/ld: ../src/libt8.a(t8_forest.cxx.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

This is due to the fact that we are trying to build a shared library libt8example.so linking the static library libt8.a which has not been compiled using position independent code. A easy fix would be to compile libt8example as a static library instead.