Linking error: DSO missing from command line

前端 未结 4 1503
孤城傲影
孤城傲影 2020-11-30 04:31

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

相关标签:
4条回答
  • 2020-11-30 04:41

    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
    
    0 讨论(0)
  • 2020-11-30 04:45

    Use the following commands to fix the issue:

    FLAGS=-lX11 ./configure --prefix=/usr --disable-static
    make
    make install
    
    0 讨论(0)
  • 2020-11-30 04:55

    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.

    0 讨论(0)
  • 2020-11-30 05:03

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

    It worked for me.

    0 讨论(0)
提交回复
热议问题