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

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

问题描述

我是来自 Windows 的 Linux(使用 Ubuntu 14.04 LTS 64 位)的新手,我正在尝试移植我现有的 CUDA 项目.

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.

通过链接时

/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

答案似乎与这篇文章中的解决方案密切相关(奇怪链接错误:命令行中缺少 DSO),但鉴于我对 Linux 的缺乏经验,我无法使它们适应我自己的问题.

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?

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

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

这是我对 Makefile 的尝试:https://gist.github.com/wbolden/135033daae04ed0d8cf3

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

推荐答案

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

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.

p>

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

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.

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

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

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

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.

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

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

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

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

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天全站免登陆