glfw3错误:命令行缺少DSO [英] glfw3 error: DSO Missing from command line
问题描述
我最近不得不在PC上重新安装Linux Mint.我重新安装了所有库,例如GLFW,并遇到了从未见过的错误.不幸的是,由于无法找到对我有用的修复程序,我的google-fu技能似乎无法与这个错误相提并论.旁注:这些程序在我的旧安装中可以正常编译,并且在运行Linux Mint 17.2的笔记本电脑上也可以完美编译.
I recently had to reinstall Linux Mint on my PC. I reinstalled all my libraries, such as GLFW and came across an error I have never seen before. Unfortunately my google-fu skills do not seem up to par for this error as I've not been able to find any fixes that work for me. Sidenote: these programs compiled fine on my old installation, and they also compile perfectly fine on my laptop that also runs Linux Mint 17.2.
这是我用来编译的编译语句:
This is the compile statement I using to compile:
g++ -std=c++11 main.cpp -o out -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi
这是航站楼向我吐出的东西:
This is what the terminal spits out at me:
/usr/bin/ld: //usr/local/lib/libglfw3.a(glx_context.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
所以,如果有人能告诉我为什么我得到这个/或如何解决这个问题,那绝对是惊人的!提前谢谢您的帮助.
So, if anyone can tell me why I'm getting this/or how to fix it that would be absolutely amazing! Thanks ahead of time for any help.
我已经重新安装了Mint两次,以尝试解决此问题.每次都会出现.
I have reinstalled Mint twice in order to try and fix this. It turns up everytime.
我一直在摆弄,但仍未找到问题.
EDIT 2: I've been fiddling around and still have yet to find an issue.
推荐答案
似乎缺少的符号来自libdl
.
作为额外的奖励,我将给您一个Makefile.请记住要使用制表符而不是空格缩进,否则Makefile将无法正常工作.
As an added bonus, I'm going to give you a Makefile. Remember to indent with tabs, NOT spaces, otherwise the Makefile won't work.
all: out
clean:
rm -f out *.o
.PHONY: all clean
CXX = g++
CPPFLAGS =
CXXFLAGS = -std=c++11 -Wall -Wextra -g
LIBS = -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -pthread -lXi -ldl
LDFLAGS =
out: main.o
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
但是,如果使用pkg-config
,会容易得多.我不知道正确的命令是什么(我现在不在Linux上,所以无法检查),但是它看起来像这样:
However, it would be a lot easier if you used pkg-config
. I don't know off the top of my head the right command (I'm not on Linux now so I can't check), but it will look like this:
packages = glfw3
CPPFLAGS := $(shell pkg-config --cflags $(packages))
LIBS := $(shell pkg-config --libs $(packages))
这样,您甚至不必知道您需要-ldl
,因为pkg-config
会为您解决.这是标准的做事方式.
This way you won't have to even know that you need -ldl
, because pkg-config
will figure it out for you. This is the standard way of doing things.
尝试自己运行pkg-config --libs glfw3
来查看输出.如果尚未安装,请运行sudo apt-get install pkg-config
.
Try running pkg-config --libs glfw3
for yourself to see the output. If it's not installed, run sudo apt-get install pkg-config
.
这篇关于glfw3错误:命令行缺少DSO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!