xmrig/xmrig-cuda

Linking error in Debian 11 - Cuda 11.8

noice78 opened this issue · 1 comments

Hello, I am getting the following error:

[100%] Linking CXX shared library libxmrig-cuda.so
/usr/bin/ld: libxmrig-cu.a(xmrig-cu_generated_cuda_extra.cu.o): warning: relocation against `_Z27cryptonight_extra_gpu_finalILN10xmrig_cuda9Algorithm2IdE1662386176EEvimPjS3_S3_S3_' in read-only section `.text._Z27cryptonight_extra_gpu_finalILN10xmrig_cuda9Algorithm2IdE1662386176EEvimPjS3_S3_S3_[_Z27cryptonight_extra_gpu_finalILN10xmrig_cuda9Algorithm2IdE1662386176EEvimPjS3_S3_S3_]'
/usr/bin/ld: libxmrig-cu.a(xmrig-cu_generated_cuda_core.cu.o): relocation R_X86_64_PC32 against symbol `_ZTISt13runtime_error' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/xmrig-cuda.dir/build.make:150: libxmrig-cuda.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/xmrig-cuda.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Tried to add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC") but didn't help...

Used:
cmake .. -DCUDA_LIB=/usr/lib/x86_64-linux-gnu/stubs/libcuda.so -DCUDA_TOOLKIT_ROOT_DIR=/usr/lib/nvidia-cuda-toolkit/ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

# gcc --version
gcc (Debian 11.3.0-12) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# clang --version
Debian clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Any help appreciated.

Solved adding -fPIC in flags.cmake for clang.