问题
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