链接错误:命令行中缺少DSO [英] Linking error: DSO missing from command line

查看:480
本文介绍了链接错误:命令行中缺少DSO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用Windows的Linux(使用Ubuntu 14.04 LTS 64bit)非常陌生,并且正尝试移植到我现有的CUDA项目上.

通过链接时

/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

我遇到以下错误:

/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

答案似乎与本文中的解决方案密切相关( Strange链接错误:命令行中缺少DSO ),尽管由于我对Linux的经验不足,所以我无法使它们适应我自己的问题.

关于可能是什么问题的任何想法?

这是编译期间的完整输出: https://gist.github.com/wbolden/857eddd11e4dcb915c02

这是我尝试的一个Makefile文件: https://gist.github.com/wbolden/135033daae04ed0d8cf3

解决方案

希望这将对像我这样的人有所帮助,像我一样,他们是Linux的新手,并且没有发现与Linux相关的任何东西特别明显. >

正如talonmies所述,我无法间接链接,因此需要指定我正在使用的库所需的任何其他库.也就是说,如果我链接需要库B和C的库A,则需要链接所有三个库以使程序正确链接.

为了找到需要的其他库,我使用了pkg-config命令,为此我找到了一个指南此处.运行pkg-config --print-requires --print-requires-private glfw3给出以下输出,这是glfw3所需的软件包的列表.

x11
xrandr
xi
xxf86vm
gl

然后,我可以通过运行pkg-config --libs以及库名找到需要包含的库.例如,pkg-config --libs x11产生-lX11.

注意:您可以将多个项目作为输入传递给pkg-config,因此运行

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

将打印出您需要链接的所有其他库(-lX11 -lXrandr -lXi -lXxf86vm -lGL).

我的程序现在可以成功链接,希望对遇到类似问题的任何人都有用.

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

解决方案

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.

这篇关于链接错误:命令行中缺少DSO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆