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.


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

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.

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.

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.