-
Bonsoir, voici mon fichier SFML.cpp:
#include <iostream>
#include </home/lol/SFML-2.1/include/SFML/System.hpp>
#include </home/lol/SFML-2.1/include/SFML/Graphics.hpp>
using namespace std;
int main(int argc, char **argv)
{
sf::RenderWindow Window(sf::VideoMode(800, 600), "My Window :D");
sf::Texture Sprite;
Window.clear(sf::Color::Black);
Window.display();
return 0;
}
(J'ai mis l'adresse complète dans les includes pour être sûr qu'il n'aille pas chercher les fichiers ailleurs)
Puis j'essaie de compiler le bestiau:
g++-4.8 -std=c++11 -o SFML SFML.cpp -Wall -lsfml-graphics -lsfml-window -lsfml-system
Et voilà ce que j'obtiens, alors que tous les fichiers .hpp pertinents sont logiquement inclus:
/tmp/ccg01oFm.o: In function `main':
SFML.cpp:(.text+0x104): undefined reference to `sf::String::String(char const*, std::locale const&)'
SFML.cpp:(.text+0x155): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
SFML.cpp:(.text+0x182): undefined reference to `sf::Texture::Texture()'
SFML.cpp:(.text+0x19a): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
SFML.cpp:(.text+0x1a9): undefined reference to `sf::Window::display()'
SFML.cpp:(.text+0x1bd): undefined reference to `sf::Texture::~Texture()'
SFML.cpp:(.text+0x212): undefined reference to `sf::Texture::~Texture()'
collect2: error: ld returned 1 exit status
Verriez-vous une explication? Merci.
-
-L/home/lol/SFML-2.1/lib peut-être ?
-
-L/home/lol/SFML-2.1/lib peut-être ?
Il n'y a aucun fichier/dossier lib dans SFML-2.1 :(
-
??
Il y a quoi alors ? Tu as obtenu ce dossier comment ?
-
??
Il y a quoi alors ? Tu as obtenu ce dossier comment ?
drwxrwxr-x 3 lol lol 4096 Jul 21 2013 cmake/
-rw-rw-r-- 1 lol lol 8620 Jul 21 2013 CMakeLists.txt
drwxrwxr-x 2 lol lol 4096 Jul 21 2013 doc/
drwxrwxr-x 14 lol lol 4096 Jul 21 2013 examples/
drwxrwxr-x 7 lol lol 4096 Jul 21 2013 extlibs/
drwxrwxr-x 3 lol lol 4096 Jul 21 2013 include/
-rw-rw-r-- 1 lol lol 1344 Jul 21 2013 license.txt
-rw-rw-r-- 1 lol lol 1693 Jul 21 2013 readme.txt
drwxrwxr-x 3 lol lol 4096 Jul 21 2013 src/
drwxrwxr-x 4 lol lol 4096 Jul 21 2013 tools/
J'ai essayé extlibs, sans succès.
Ca date de quelques mois (par démotivation de faire compiler le truc, j'étais passé à autre chose) mais il me semble avoir installé SFML en suivant les tutos sur le site officiel.
-
Ca ce sont les sources de SFML. Tu n'as aucune bibliothèque compilée dedans. Du coup celles que l'éditeur de lien trouve sont ailleurs et très probablement d'une autre version que tu avais précédemment installée (potentiellement via le gestionnaire de paquets de ton système).
-
Ca ce sont les sources de SFML. Tu n'as aucune bibliothèque compilée dedans. Du coup celles que l'éditeur de lien trouve sont ailleurs et très probablement d'une autre version que tu avais précédemment installée (potentiellement via le gestionnaire de paquets de ton système).
Ok du coup j'ai regardé le path par défaut, et j'ai vu qu'il contenait tout mon dossier SFML-2.1 dans home, plus d'autres choses comme justement lib. Donc j'ai modifié mes includes de la façon suivante:
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
Mais j'obtiens exactement les mêmes problèmes:
/tmp/ccsjt4n1.o: In function `main':
SFML.cpp:(.text+0x104): undefined reference to `sf::String::String(char const*, std::locale const&)'
SFML.cpp:(.text+0x155): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
SFML.cpp:(.text+0x182): undefined reference to `sf::Texture::Texture()'
SFML.cpp:(.text+0x19a): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
SFML.cpp:(.text+0x1a9): undefined reference to `sf::Window::display()'
SFML.cpp:(.text+0x1bd): undefined reference to `sf::Texture::~Texture()'
SFML.cpp:(.text+0x212): undefined reference to `sf::Texture::~Texture()'
collect2: error: ld returned 1 exit status
Voilà ce que contient /usr/local/lib :
total 13768
drwxr-xr-x 6 root root 4096 Jul 8 22:53 ./
drwxr-xr-x 11 root root 4096 Nov 9 2013 ../
lrwxrwxrwx 1 root root 20 Jan 15 18:26 libSDL2-2.0.so.0 -> libSDL2-2.0.so.0.0.0*
-rwxr-xr-x 1 root root 4630262 Jan 15 18:26 libSDL2-2.0.so.0.0.0*
-rw-r--r-- 1 root root 8569624 Jan 15 18:26 libSDL2.a
-rwxr-xr-x 1 root root 948 Jan 15 18:26 libSDL2.la*
-rw-r--r-- 1 root root 5652 Jan 15 18:26 libSDL2main.a
lrwxrwxrwx 1 root root 20 Jan 15 18:26 libSDL2.so -> libSDL2-2.0.so.0.0.0*
-rw-r--r-- 1 root root 148846 Jan 15 18:26 libSDL2_test.a
lrwxrwxrwx 1 root root 18 Jan 15 20:34 libsfml-audio.so -> libsfml-audio.so.2
lrwxrwxrwx 1 root root 20 Jan 15 20:34 libsfml-audio.so.2 -> libsfml-audio.so.2.1
-rw-r--r-- 1 root root 85271 Jul 8 22:53 libsfml-audio.so.2.1
lrwxrwxrwx 1 root root 21 Jan 15 20:34 libsfml-graphics.so -> libsfml-graphics.so.2
lrwxrwxrwx 1 root root 23 Jan 15 20:34 libsfml-graphics.so.2 -> libsfml-graphics.so.2.1
-rw-r--r-- 1 root root 313414 Jul 8 22:52 libsfml-graphics.so.2.1
lrwxrwxrwx 1 root root 20 Jan 15 20:34 libsfml-network.so -> libsfml-network.so.2
lrwxrwxrwx 1 root root 22 Jan 15 20:34 libsfml-network.so.2 -> libsfml-network.so.2.1
-rw-r--r-- 1 root root 133651 Jul 8 22:52 libsfml-network.so.2.1
lrwxrwxrwx 1 root root 19 Jan 15 20:34 libsfml-system.so -> libsfml-system.so.2
lrwxrwxrwx 1 root root 21 Jan 15 20:34 libsfml-system.so.2 -> libsfml-system.so.2.1
-rw-r--r-- 1 root root 54420 Jul 8 22:52 libsfml-system.so.2.1
lrwxrwxrwx 1 root root 19 Jan 15 20:34 libsfml-window.so -> libsfml-window.so.2
lrwxrwxrwx 1 root root 21 Jan 15 20:34 libsfml-window.so.2 -> libsfml-window.so.2.1
-rw-r--r-- 1 root root 106685 Jul 8 22:52 libsfml-window.so.2.1
drwxr-xr-x 2 root root 4096 Jul 8 22:53 pkgconfig/
drwxrwsr-x 4 root staff 4096 Mar 6 13:00 python2.7/
drwxrwsr-x 3 root staff 4096 Mar 7 17:12 R/
drwxr-xr-x 3 root root 4096 Dec 2 2013 site_ruby/
-
Donc, pas d'idée?
-
As tu déja un jour fait fonctionné la SFML? Ou c'est la première fois que tu l'installe?
Si jamais tu veut avoir les libs tu peu utiliser mon programme pour recompiler la SFML (http://fr.sfml-dev.org/forums/index.php?topic=15859.0 ) , cependant il ne marche que pour window.