nvcc linking and -soname compiling a c project that uses the -soname option
I am trying to compile a C project that uses Make and Configure with nvcc because I wan't to re-write part of it in CUDA. When I run the configure script I pass CC=nvcc so that it uses nvcc as the compiler which works, but when it tries to link something I get the error:

nvcc fatal : Unknown option 'WL,-soname'

I could edit the Configure script to not pass that option but that wouldn't help because without specifying the shared object name as being different from the filename the program won't link properly. How can I fix this problem? Does nvcc support this option with some alias, or can I use a different linker?

Thanks in advance, boonofcake.

EDIT:

The specific line the compilation process is failing on is:

libtool: link: nvcc -shared .O_FILES -L LIB_FILES -WL,-soname

How can I tell automake to use something other than nvcc to link? I am passing the environment variable LD=ld

Shouldn't it be:

libtool: link: ld -shared .O_FILES -L LIB_FILES -WL,-soname
I am trying to compile a C project that uses Make and Configure with nvcc because I wan't to re-write part of it in CUDA. When I run the configure script I pass CC=nvcc so that it uses nvcc as the compiler which works, but when it tries to link something I get the error:



nvcc fatal : Unknown option 'WL,-soname'



I could edit the Configure script to not pass that option but that wouldn't help because without specifying the shared object name as being different from the filename the program won't link properly. How can I fix this problem? Does nvcc support this option with some alias, or can I use a different linker?



Thanks in advance, boonofcake.



EDIT:



The specific line the compilation process is failing on is:



libtool: link: nvcc -shared .O_FILES -L LIB_FILES -WL,-soname



How can I tell automake to use something other than nvcc to link? I am passing the environment variable LD=ld



Shouldn't it be:



libtool: link: ld -shared .O_FILES -L LIB_FILES -WL,-soname

#1
Posted 06/01/2011 07:32 AM   
You can savely use gcc (or whatever your favorite compiler is) for the linking stage if you pass it [font="Courier New"]-lcudart[/font] to include the CUDA runtime library.
I would even go a step further and compile all files with gcc except the ones with CUDA code. There always is a small possibility that the CUDA language extensions interfere with conventional code, particularly in the header files. Happened to me a few times with the GUI libraries.
You can savely use gcc (or whatever your favorite compiler is) for the linking stage if you pass it -lcudart to include the CUDA runtime library.

I would even go a step further and compile all files with gcc except the ones with CUDA code. There always is a small possibility that the CUDA language extensions interfere with conventional code, particularly in the header files. Happened to me a few times with the GUI libraries.

Always check return codes of CUDA calls for errors. Do not use __syncthreads() in conditional code unless the condition is guaranteed to evaluate identically for all threads of each block. Run your program under cuda-memcheck to detect stray memory accesses. If your kernel dies for larger problem sizes, it might exceed the runtime limit and trigger the watchdog timer.

#2
Posted 06/01/2011 08:04 AM   
Ok but how using automake can I compile my project with one compiler and another linker? Or with two different compilers (using nvcc only for .cu)

This project builds multiple binaries and has dozens of source files, building it manually is not an option.
Ok but how using automake can I compile my project with one compiler and another linker? Or with two different compilers (using nvcc only for .cu)



This project builds multiple binaries and has dozens of source files, building it manually is not an option.

#3
Posted 06/01/2011 08:55 AM   
Just add a pattern matching rule in the make file which uses nvcc to compiler .cu files to objects, perhaps something like

[code]%.o : %.cu
$(NVCC) $(CUFLAGS) -c -o $@ $<
[/code]

then link the resulting object files using gcc as usual, with the necessary CUDA libraries added to the link statement.
Just add a pattern matching rule in the make file which uses nvcc to compiler .cu files to objects, perhaps something like



%.o : %.cu

$(NVCC) $(CUFLAGS) -c -o $@ $<




then link the resulting object files using gcc as usual, with the necessary CUDA libraries added to the link statement.

#4
Posted 06/01/2011 10:06 AM   
Scroll To Top