can't run a program that uses sfml in Linux

荒凉一梦 提交于 2019-12-13 01:43:59

问题


I am running Linux Mint. The version information is as follows:

$ cat /etc/*-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=12
DISTRIB_CODENAME=lisa
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"

I installed sfml by downloading the tar file, going into the sfml folder, and running sudo make install. It does not give me any error messages so it seems safe to assume that it installed successfully.

I wrote the clock.cpp program given in this tutorial. I compile it using the following commands:

$ g++ -c clock.cpp
$ g++ -o clock clock.o -lsfml-system

It gives me no output, so I assume that the compilation went just fine. But the problem starts when I try to run it. This is the result of me trying to run the clock executable:

$ ./clock
./clock: error while loading shared libraries: libsfml-system.so.1.6: 
         cannot open shared object file: No such file or directory

I try the second compilation option that the tutorial gives, and the same thing happens:

$ g++ -c clock.cpp
$ g++ -o clock clock.o -lsfml-graphics -lsfml-window -lsfml-system
./clock: error while loading shared libraries: libsfml-system.so.1.6: 
         cannot open shared object file: No such file or directory

Why can't I run the program?


回答1:


You must install development library for libsfml:

sudo apt-get install libsfml-dev

next step:

apt-get build-dep libsfml

dev version of package is required because header files are necessary

such special libraries are usually installed with apt




回答2:


I don't know why, but you must run it as superuser.

sudo ./a.out


来源:https://stackoverflow.com/questions/15455914/cant-run-a-program-that-uses-sfml-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!