[英]Error while loading shared libraries when compiling a SFML 2.0 project
I tried to compile sfml 2.0. 我试图编译sfml 2.0。 At first I wrote this command:
首先,我编写了以下命令:
g++ -c sprite.cpp -I sfml/include
Every files are on my desktop now and the folder that contains the sfml files is called sfml and it is on my desktop also. 现在每个文件都在我的桌面上,包含sfml文件的文件夹称为sfml,它也在我的桌面上。
After this command, I wrote: 执行此命令后,我写道:
g++ -o sprite sprite.o -L sfml/lib -lsfml-graphics -lsfml-window -lsfml-system
After this, I simply did: 在此之后,我只是做了:
./sprite
The problem is here. 问题在这里。 When I try to run it i get:
当我尝试运行它时,我得到:
./sprite: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
The loader could not find the library libsfml-graphics.so.2
. 加载程序找不到库
libsfml-graphics.so.2
。 It seems that this library is located under sfml/lib
. 该库似乎位于
sfml/lib
。
Once solution consists in adding the location to the environment variable LD_LIBRARY_PATH
and exporting it before running your executable: 解决方案包括将位置添加到环境变量
LD_LIBRARY_PATH
并在运行可执行文件之前将其导出:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:sfml/lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.