Hello,
I am currently developping a CUDA static library. This library contains C++ and CUDA source code. Here an extract of the make process:
...
g++ -DHAVE_CONFIG_H -I. -I./include/ -I./src/ -g -O2 -MT my_gpu_C.o -MD -MP -MF .deps/my_gpu_C.Tpo -c -o my_gpu_C.o `test -f 'src/bindings/C/my_gpu_C.cpp' || echo './'`src/bindings/C/my_gpu_C.cpp
...
nvcc -arch sm_13 -O3 --compiler-options -fno-strict-aliasing -I./include/ -I./src/ -c src/cudafct.cu -o src/cudafct.o
nvcc -arch sm_13 -O3 --compiler-options -fno-strict-aliasing -I./include/ -I./src/ -c src/memory_management.cu -o src/memory_management.o
ar cru libmy_gpu.a my_gpu_C.o fct_call_implementation.o localqueu.o init_network.o manage_cpu_affinity.o read_conf_file.o set_repartition.o src/cudafct.o src/memory_management.o
This actually produce libmy_gpu.a
In my_gpu_C.cpp, there is a function mygpu_init().
I can see it with:
nm --print-armap libmy_gpu.a | grep sg_init
23:mygpu_init in my_gpu_C.o
But when I am trying with a simple C code, I have this error during the link process:
gcc -I../include -L.. -lmy_gpu hello.c -o hello
/tmp/ccoSdBbg.o: In function `main':
hello.c:(.text+0x1d): undefined reference to `mygpu_init'
collect2: ld returned 1 exit status
However, everything is fine when I compile with nvcc:
nvcc -I../include -L.. -lmy_gpu hello.c -o hello
is OK.
Am I missing something? Is it possible to compile a simple C program with gcc, when all the CUDA function are in the library?
Thanks