Bendr0id / xmrigCC

RandomX, CryptoNight, Argon2 and GhostRider CPU/GPU miner with Command&Control (CC) Server and Monitoring
GNU General Public License v3.0
311 stars 108 forks source link

Problems with compiling a static build #387

Closed PsychoSec2 closed 2 years ago

PsychoSec2 commented 2 years ago

Hey @Bendr0id, I'm trying to compile a static build for my rigs. I am planning on using custom code but as a test I'm using the fresh source code from the repo. The only thing changed is the BUILD_STATIC option which I set to ON in the CMakeLists.txt file.

When I try to build get this error:


[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libpthread.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libdl.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libuv.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libpthread.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/librt.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libdl.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libhwloc.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libuv.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libpthread.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/librt.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libhwloc.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.so'
[build] /usr/bin/ld: attempted static link of dynamic object `/lib/x86_64-linux-gnu/libm.so.6'
[build] /usr/bin/ld: attempted static link of dynamic object `/lib/x86_64-linux-gnu/libmvec.so.1'
[build] /usr/bin/ld: attempted static link of dynamic object `/lib/x86_64-linux-gnu/libc.so.6'
[build] /usr/bin/ld: attempted static link of dynamic object `/lib64/ld-linux-x86-64.so.2'
[build] collect2: error: ld returned 1 exit status
[build] gmake[2]: *** [CMakeFiles/xmrigMiner.dir/build.make:3039: xmrigMiner] Error 1
[build] gmake[1]: *** [CMakeFiles/Makefile2:186: CMakeFiles/xmrigMiner.dir/all] Error 2
[build] gmake: *** [Makefile:91: all] Error 2
[build] Build finished with exit code 2````
Bendr0id commented 2 years ago

Hi, This won't work like you do it. With a system on libc you can't create a full static build. It has always depencies to the platform glibc libs.

If you want to create a full static build you need to use a system like Alpine which uses musl instead.

Regards,

PsychoSec2 commented 2 years ago

@Bendr0id Thanks for fast reply! I'll try to start up a Alpine VM and see if I can make a static build from there! If I have any issues then I'll post it here. Much thanks!

Bendr0id commented 2 years ago

If your rigs don't run on a various of different Linux distributions, a non static build but with using static dependency libs (openssl, libuv, hwloc) will also work.

PsychoSec2 commented 2 years ago

Compiled it using an Alpine VM and followed build instructions, everything works perfectly!

martin-braun commented 10 months ago

@Bendr0id I tried to do it as you told, because fully dynamically linked isn't possible anymore, because Debian doesn't have libssl 1.1 anymore. So I thought it is necessary to build some deps and link them statically. I did this:

(cd scripts && ./build_deps.sh)
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DXMRIG_DEPS=../scripts/deps -DWITH_OPENCL=OFF -DWITH_CUDA=OFF ..
cmake --build . --config Release

It still complains:

$ ./xmrigServer
./xmrigServer: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory