Closed stephanmg closed 3 years ago
The CMake-generated link line for ugshell
with -DSTATIC_BUILD=ON
looks like this:
/opt/rh/devtoolset-8/root/usr/bin/g++ -std=c++98 -Wall -Wno-multichar -O3 -DNDEBUG -funroll-loops -ftree-vectorize CMakeFiles/ugshell.dir/ugshell_main.cpp.o CMakeFiles/ugshell.dir/shell.cpp.o CMakeFiles/ugshell.dir/main.cpp.o CMakeFiles/ugshell.dir/completion.cpp.o CMakeFiles/ugshell.dir/externals/linenoise/linenoise.cpp.o -o ../../../../bin/ugshell -L/home/lampe/ug4/ugcore/cmake/../../lib -rdynamic -Wl,-Bdynamic -llapack -lblas -Wl,-Bstatic -ldl -Wl,-Bdynamic /usr/local/openmpi-gcc-1.8.8/lib/libmpi_cxx.so /usr/local/openmpi-gcc-1.8.8/lib/libmpi.so ../../../../lib/libug4_s.a -lsuperlu ../../../../lib/libparmetis.a ../../../../lib/libmetis.a -llapack -lblas -Wl,-Bstatic -ldl -Wl,-Bdynamic /usr/local/openmpi-gcc-1.8.8/lib/libmpi_cxx.so /usr/local/openmpi-gcc-1.8.8/lib/libmpi.so -Wl,-Bstatic -lm -Wl,-rpath,/home/lampe/ug4/ugcore/cmake/../../lib:/usr/local/openmpi-gcc-1.8.8/lib
The final -Wl,-Bstatic
makes the linker look for libgcc_s.a
-- which doesn't exist (at all).
@mlampe this is true. I'm sorry I did not post my make VERBOSE=1
output.
I'm not sure, should I hunt for the CMakeLists.txt to address this? Yes, this gives me the same thing:
... Wl,-Bstatic -lm -Wl,-rpath,/home/sgrein/Code/git/ug4/ugcore/cmake/../../lib:/usr/local/openmpi-gcc-1.8.8/lib ...
What is the intended effect of -DSTATIC_BUILD=ON
at link time? Without knowing this, it's hard to fix anything.
What is the intended effect of
-DSTATIC_BUILD=ON
at link time? Without knowing this, it's hard to fix anything.
I agree. For my purposes I can switch to -DSTATIC_BUILD=OFF
and this works well... but for the general audience maybe it might be interesting how to fix this and compile statically e.g. on a cluster.
Do you want a fully static binary or a binary that statically links ug4, when you say -DSTATIC_BUILD=ON
?
Actually I'm fine with my -DSTATIC_BUILD=OFF
UG 4 version. I just assumed that when making use of the -DSTATIC_BUILD=ON
option the build should succeed in the end.
It works on systems than can only do static linking. It's systems that can do both and default to dynamic linking for which cmake produces this non-working link line.
@mlampe: Thanks for clarification. I assume one would want a fully static binary. But I guess one should wait for other opinions on this issue. To this end... should this issue remain open?
STATIC_BUILD=ON
now links all parts of ug4+plugins statically into one binary with system libraries following the system's default.
Static build with target ugshell won't find lib gcc_s on Ubuntu Xenial Xerus to link ugshell.
Error:
Running
ldconfig -p | grep libgcc
showslibgcc_s.so.1
thus I tried to symlink to the library by:ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so
No success here...Secondly Static build with target libug4 results in another error, see below:
Error:
Building with STATIC_BUILD=OFF succeeds for targets shell and VRL. (Didn't try libug4).
Any hints how to fix this?
Best wishes, SG