= note: /home/cery/workspace/duck_plotter/duck_plotter/target/debug/deps/duck_plotter-f93f106965cf8cad.4uyjisg3s5qfcw7q.rcgu.o: In function `duck_plotter::main':
/home/cery/workspace/duck_plotter/duck_plotter/src/main.rs:39: undefined reference to `check_gpu'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_shabal256.cu.o): In function `Check_Cuda_Status()':
/home/cery/workspace/duck_plotter/cuda_shabal256/cuda_shabal256.cu:7: undefined reference to `cudaGetDeviceCount'
/home/cery/workspace/duck_plotter/cuda_shabal256/cuda_shabal256.cu:11: undefined reference to `cudaGetDeviceProperties'
/home/cery/workspace/duck_plotter/cuda_shabal256/cuda_shabal256.cu:21: undefined reference to `cudaGetLastError'
/home/cery/workspace/duck_plotter/cuda_shabal256/cuda_shabal256.cu:21: undefined reference to `cudaGetLastError'
/home/cery/workspace/duck_plotter/cuda_shabal256/cuda_shabal256.cu:21: undefined reference to `cudaGetErrorString'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_shabal256.cu.o): In function `__cudaUnregisterBinaryUtil()':
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_runtime.h:259: undefined reference to `__cudaUnregisterFatBinary'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_shabal256.cu.o): In function `__nv_init_managed_rt_with_module(void**)':
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_runtime.h:264: undefined reference to `__cudaInitModule'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_shabal256.cu.o): In function `__sti____cudaRegisterAll()':
/tmp/tmpxft_000028a7_00000000-5_cuda_shabal256.cudafe1.stub.c:14: undefined reference to `__cudaRegisterLinkedBinary_49_tmpxft_000028a7_00000000_6_cuda_shabal256_cpp1_ii_4b73c76e'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__cudaUnregisterBinaryUtil()':
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_runtime.h:259: undefined reference to `__cudaUnregisterFatBinary'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__nv_init_managed_rt_with_module(void**)':
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_runtime.h:264: undefined reference to `__cudaInitModule'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__device_stub__Z15generate_nouncePhmm(unsigned char*, unsigned long, unsigned long)':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:17: undefined reference to `__cudaPopCallConfiguration'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__device_stub__Z16swap_poc2_formatPhm(unsigned char*, unsigned long)':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaPopCallConfiguration'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__device_stub__Z19clip_mem2poc_formatPhS_(unsigned char*, unsigned char*)':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaPopCallConfiguration'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__device_stub__Z31generate_compressed_poc2_formatPhS_(unsigned char*, unsigned char*)':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaPopCallConfiguration'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__nv_cudaEntityRegisterCallback(void**)':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction'
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction'
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction'
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:1: undefined reference to `__cudaRegisterFunction'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `__sti____cudaRegisterAll()':
/tmp/tmpxft_0000066c_00000000-5_cuda_nounce.cudafe1.stub.c:2: undefined reference to `__cudaRegisterLinkedBinary_46_tmpxft_0000066c_00000000_6_cuda_nounce_cpp1_ii_69bad568'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o): In function `cudaError cudaLaunchKernel<char>(char const*, dim3, dim3, void**, unsigned long, CUstream_st*)':
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:209: undefined reference to `cudaLaunchKernel'
/home/cery/workspace/duck_plotter/duck_plotter/cuda_lib/libcuda_shabal256.a(cuda_nounce.cu.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
The post does not seem to provide sufficient information, e.g. problem description, compiler version, compile command, crates used, code snippet that causes the problem, etc. Providing these may make it easier for others to identify problems.
From the error message it seems the linker could not find all the symbols from the CUDA library, and most of them are from libcudart
. Probably you could change your linker to nvcc
, which knows how to find the libs, or you could specify the path of all libraries that you need to link against to your current linker.
how to change link to nvcc ? i am a newer
Could you please elaborate these information?
In addition, environment variables like $LD_LIBRARY_PATH
.
Without these information it's hard for others to help you identify problems.
Before having these information, I could only take a guess. In most cases it's easier to specify the path of all libraries that you need to link with than to change a linker. For linkage issue, there are typically three cases:
- you did not specify the library to be linked with;
- you did not specify the path of the libraries to be searched in;
- both of above.
Solution for problem 1:
-
Case I: If you have some
extern "C"
blocks in your rust code and you could change it:- Change it to
#[link(name = "cudart")] extern "C" {...}
- Change it to
-
Case II: If you would like to temporarily change your
$RUSTFLAGS
:- Use
RUSTFLAGS="-lcudart" cargo build
when building.
- Use
-
Case III: If you want to set this flag in build scripts, see Alternative Solution.
Solution for problem 2:
-
Case I: If you would like to temporarily change your
$LD_LIBRARY_PATH
:- Do
export LD_LIBRARY_PATH="folder/of/cudalibs:$LD_LIBRARY_PATH"
in you command line. Replacefolder/of/cudalibs
with the actually path of you cuda lib. It's likely/usr/local/cuda/lib64
on Linux.
- Do
-
Case II: If you would like to temporarily change your
$RUSTFLAGS
:- Use
RUSTFLAGS="-Lfolder/of/cudalibs" cargo build
when building. It can be combined with Case II for problem 1 as:RUSTFLAGS="-Lfolder/of/cudalibs -lcudart" cargo build
if you want both.
- Use
-
Case III: If you want to set this flag in build scripts, see Alternative Solution.
Alternative Solution: Build scripts
-
In your
Cargo.toml
, addbuild = "build.rs"
to the[package]
section. -
Add a
build.rs
file in your project root, and writefn main() { ... }
-
For problem 1:
- In
...
, add a lineprintln!("cargo:rustc-link-lib=cudart");
- In
-
For problem 2:
- In
...
, add a lineprintln!("cargo:rustc-link-search=native=folder/of/cudalibs");
. Replacefolder/of/cudalibs
with the actually path of you cuda lib.
- In
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.