22

I am rather new to Linux (using Ubuntu 14.04 LTS 64bit), coming from Windows, and am attempting to port over an existing CUDA project of mine.

When linking via

/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart

I encounter the following error:

/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to  symbol 'XConvertSelection'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [CUDANN] Error 1

The answer seems closely related to the solutions in this post (Strange linking error: DSO missing from command line), though given my inexperience with Linux I was unable to adapt them to my own problem.

Any ideas on what the problem could be?

Here is the full output during compilation: https://gist.github.com/wbolden/857eddd11e4dcb915c02

And here is my attempt at a Makefile: https://gist.github.com/wbolden/135033daae04ed0d8cf3

Community
  • 1
  • 1
Will Bolden
  • 810
  • 1
  • 7
  • 13
  • The linker is telling you exactly what the problem is, and the answer you linked to tells you exactly what to do to fix it. You are clearly running on a platform that disallows indirect linking. Add the library dependencies for the required additional libraries (hint libX11 is shown right in the linker error message). I am removing the CUDA tag from this question, it has nothing to do with CUDA or CUDA programming. – talonmies Jul 28 '14 at 06:29
  • 8
    As I said, I am rather new to Linux (I've only been working with it for a few days), so what might be clear to someone with even moderate experience is not all that clear to me. Using ldd I get the following https://gist.github.com/WilliamHBolden/51a8721b4f8d89df2cef though I don't understand what to do with it. I tried adding -L/usr/x86_64-linux-gnu and -L/lib64 but that did not change the error. – Will Bolden Jul 28 '14 at 06:55
  • Maybe you must leave gist or use other system because now gist are not available – Juan Garcia Jul 26 '16 at 14:09
  • 1
    My username changed, replace WilliamHBolden with wbolden – Will Bolden Jul 27 '16 at 19:16
  • Also see [Strange linking error: DSO missing from command line](http://stackoverflow.com/q/19901934), [DSO missing from command line](http://stackoverflow.com/q/24096807), and [Linking error: DSO missing from command line](http://stackoverflow.com/q/24989432). – jww Jan 09 '17 at 20:47
  • Possible duplicate of [Strange linking error: DSO missing from command line](http://stackoverflow.com/questions/19901934/strange-linking-error-dso-missing-from-command-line) – jww Jan 09 '17 at 20:48

4 Answers4

39

Hopefully this will be of help to those, like me, who are new to Linux and don't find anything related to Linux to be particularly obvious.

As noted by talonmies, I am not able to link indirectly and as such need to specify any additional libraries required by the libraries I am using. That is to say, if I link library A, which requires libraries B and C, I need to link all three libraries for the program to link correctly.

To find what other libraries were needed I used the pkg-config command, for which I found a guide here. Running pkg-config --print-requires --print-requires-private glfw3 gave the following output, which is the list of packages required by glfw3.

x11
xrandr
xi
xxf86vm
gl

I was then able to find what libraries I needed to include by running pkg-config --libs, followed by the name of the library. For example, pkg-config --libs x11 yielded -lX11.

Note: you can pass multiple items to pkg-config as input, so running

pkg-config --libs $(pkg-config --print-requires --print-requires-private glfw3)

will print out all the additional libraries you need to link (-lX11 -lXrandr -lXi -lXxf86vm -lGL).

My program now links successfully, I hope this helpful to anyone with a similar problem.

Will Bolden
  • 810
  • 1
  • 7
  • 13
7

Your linker need X11 library,You need to specify -lX11 to linker

Try

/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart -lX11
Rahul R Dhobi
  • 5,668
  • 1
  • 29
  • 38
  • I tried doing this earlier in the day and it unfortunately did not resolve my problem. Here is the new error I got https://gist.github.com/WilliamHBolden/225d2064f844d33d958f – Will Bolden Jul 28 '14 at 06:59
  • @will bolden: this answer does solve your problem. Adding the x11 library eliminated the dso error. Now you have unsatisfied dependencies. Add those. – talonmies Jul 28 '14 at 15:51
1

Try to add -pthread at the end of the library list (command line) in the Makefile.

It worked for me.

Ricky
  • 79
  • 1
  • 8
0

Use the following commands to fix the issue:

FLAGS=-lX11 ./configure --prefix=/usr --disable-static
make
make install
hB0
  • 1,977
  • 1
  • 27
  • 33
  • 7
    Would you care to add some more reasoning, what is the error and how this fixes it? – hB0 Feb 20 '17 at 21:26