[SOLVED] Error while linking with nvcc

Hello,

I am trying to compile and link a CUDA project with the option -Wl,-rpath,libs/x86_64. For do it I add the option Xcompiler:

-Xcompiler -Wl,-rpath,libs/x86_64

but I get the follow error:

gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-rpath’

Also I tried to add a quotation marks:

-Xcompiler -Wl",-rpath,libs/x86_64"

an then I get the follow error:

nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

I’m not sure if I need to put the quotations and if it is necessary I’m not sure where I need to put it. I tried to put the quotations in different positions but I get the same error…

Any idea?

Thank you

The basic problem seems to be that -Xcompiler takes a single flag, but what you have right now is parsed as multiple flags, or a fla plus a filename, by the command-line parser. What happens if you try:

-Xcompiler "-Wl,-rpath,libs/x86_64"

or

-Xcompiler \"-Wl,-rpath,libs/x86_64\"

I don’t know whether the command-line parse “respects” quotation marks for grouping. Can the same information be supplied by separate command-line flags, rather than a compound one, e.g.

-Xcompiler -Wl -Xcompiler -rpath"libs/x86_64"

Hi njuffa,

I’ve tried it the way you said and I have the follow results:

  • When I tried with -Xcompiler “-Wl,-rpath,libs/x86_64” I got the error
gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-rpath’

-When I tried with -Xcompiler “-Wl,-rpath,libs/x86_64” I got the error

nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified
  • Finally I tried with -Xcompiler -Wl -Xcompiler -rpath"libs/x86_64" and I got the error
gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-rpathlibs/x86_64’

Also I tried with -Xcompiler -Wl -Xcompiler -rpath=libs/x86_64 and -Xcompiler -Wl -Xcompiler -rpath"libs/x86_64" and I got the same error

gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-rpathlibs/x86_64’

I don’t understand the problem…

This method will work:

-Xcompiler “-Wl,-rpath,libs/x86_64”

The error you are getting at that point is due to some other problem in your compile command line, which you have not shown.

Hi,

I am trying to execute some cuda test with Netbeans.

If I compile the project it works fine but when I want to execute the tests I have this problem. I think that the error is in my make files but I don’t understand this because the configuration for tests is the same of the project…

Hi,

I have found the error. The problem was in the makefile. I added the option -Xcompiler “-Wl,-rpath,libs/x86_64” with the graphical interface in Netbeans but for some reason the make file was not update. I have edit the file configurations.xml and I have add the configuration option and now the makefiles is correct and works fine.

Thank you.