HiGHS icon indicating copy to clipboard operation
HiGHS copied to clipboard

Building static executable fails

Open laszloladanyi opened this issue 3 years ago • 1 comments

When running 'cmake -DFAST_BUILD=ON .." and then building highs there are several problems. I figured these out on ubuntu 20.04, but I presume they are present elsewhere as well. First, pthread is not found. That can be remedied by specifying CC="gcc -pthread" CXX="g++ -pthread".

After this highs builds, but the resulting executable is not static, it depends on libstdc++.so, libm.so, and libz.so. To coax the build system to make a truly static executable these are the steps I had to take: mkdir build-20220426 cd build-20220426 CC="gcc -static -static-libstdc++ -pthread" CXX="g++ -static -static-libstdc++ -pthread" cmake -DFAST_BUILD=ON .. sed -i -e 's|/usr/lib/x86_64-linux-gnu/libz.so|/usr/lib/x86_64-linux-gnu/libz.a|' app/CMakeFiles/highs.dir/link.txt sed -i -e 's|/usr/lib/x86_64-linux-gnu/libz.so|/usr/lib/x86_64-linux-gnu/libz.a|' app/CMakeFiles/highs.dir/build.make make -j8 FAST_BUILD should automatically turn on -static and -static-libstdc++ for gcc (and the equivalent on other platforms) and it should point to the static libz instead of the shared one. Oh, and pthread should be found :-).

--Laci

laszloladanyi avatar Apr 26 '22 18:04 laszloladanyi

Hi Laci,

I am surprised Threads was not found, works on our test systems, including Ubuntu. Perhaps CMake needs a flag to point to the threads installation on your machine?

What are you trying to do, with a truly static executable? Including standard libraries into the build is not something we considered due to possible complications.

We updated the CMake code for fast build, so would you please try again with an updated version of master?

Thanks, Ivet

galabovaa avatar May 31 '22 11:05 galabovaa

Hi @laszloladanyi, we made some further updates to the build system, since we have not heard from you in a while I will close this issue. Please try again with v1.5.3 or a future latest version and please open another issue if you run into further problems.

Ivet

galabovaa avatar May 27 '23 13:05 galabovaa