Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: Configuration SFML code block  (Lu 4588 fois)

0 Membres et 1 Invité sur ce sujet

arzop

  • Newbie
  • *
  • Messages: 7
    • Voir le profil
    • E-mail
Configuration SFML code block
« le: Juillet 02, 2016, 10:20:10 pm »
Bonjour a tous, j essaye de faire fonctionner SFML avec code block mais comme vous pouvez vous y attendre, je n y arrive pas.
Il me semble avoir pourtant avoir suivi le tuto mais ren ne fait, voici ce que j'ai:



#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

et voici les erreurs:

\Program Files (x86)\CodeBlocks\MinGW\lib\liballeg_s.a||No such file or directory|
et ca 8 fois)

Meme en comprenant le type d erreur, je ne sais pas comment les resoudre.

Merci

G.

  • Hero Member
  • *****
  • Messages: 1593
    • Voir le profil
Re : Configuration SFML code block
« Réponse #1 le: Juillet 02, 2016, 10:55:14 pm »
liballeg ? C'est genre Allegro ? Tu as pas utilisé Allegro avant et oublié d'en enlever le lien dans les options du linker ?

arzop

  • Newbie
  • *
  • Messages: 7
    • Voir le profil
    • E-mail
Re : Configuration SFML code block
« Réponse #2 le: Juillet 02, 2016, 11:12:25 pm »
En effet, j ai testé allegro avant et je croyais avoir fait le menage.

Apres avoir tout nettoye, voila ce que j'ai:

||=== Build: Debug in testSFML (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
E:\C++\testSFML\main.cpp|5|undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
E:\C++\testSFML\main.cpp|5|undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
E:\C++\testSFML\main.cpp|5|undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
E:\C++\testSFML\main.cpp|6|undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
E:\C++\testSFML\main.cpp|7|undefined reference to `_imp___ZN2sf5Color5GreenE'|
E:\C++\testSFML\main.cpp|7|undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'|
E:\C++\testSFML\main.cpp|15|undefined reference to `_imp___ZN2sf6Window5closeEv'|
E:\C++\testSFML\main.cpp|12|undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
E:\C++\testSFML\main.cpp|18|undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
E:\C++\testSFML\main.cpp|18|undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
E:\C++\testSFML\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'|
E:\C++\testSFML\main.cpp|19|undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
E:\C++\testSFML\main.cpp|20|undefined reference to `_imp___ZN2sf6Window7displayEv'|
E:\C++\testSFML\main.cpp|9|undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
E:\C++\testSFML\main.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
E:\C++\testSFML\main.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
E:\C++\testSFML\main.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev':|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
||error: ld returned 1 exit status|
||=== Build failed: 21 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

G.

  • Hero Member
  • *****
  • Messages: 1593
    • Voir le profil
Re : Configuration SFML code block
« Réponse #3 le: Juillet 02, 2016, 11:17:50 pm »
Est-ce que tu lies les lib statiques (sfml-graphics-s par exemple) sans définir SFML_STATIC ?
(Ou l'inverse, tu définis SFML_STATIC mais tu lies les versions dynamiques (sfml-graphics par exemple))

arzop

  • Newbie
  • *
  • Messages: 7
    • Voir le profil
    • E-mail
Re : Configuration SFML code block
« Réponse #4 le: Juillet 02, 2016, 11:22:17 pm »
Je n avais pas defini le SFML_STATIC partout (je ne sais pas si ca a une incidence) en tout cas les erreurs semblent etre les memes

||=== Build: Debug in testSFML (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
E:\C++\testSFML\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
E:\C++\testSFML\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
E:\C++\testSFML\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
E:\C++\testSFML\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
E:\C++\testSFML\main.cpp|7|undefined reference to `sf::Color::Green'|
E:\C++\testSFML\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
E:\C++\testSFML\main.cpp|15|undefined reference to `sf::Window::close()'|
E:\C++\testSFML\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
E:\C++\testSFML\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
E:\C++\testSFML\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
E:\C++\testSFML\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
E:\C++\testSFML\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
E:\C++\testSFML\main.cpp|20|undefined reference to `sf::Window::display()'|
E:\C++\testSFML\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
E:\C++\testSFML\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
E:\C++\testSFML\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
E:\C++\testSFML\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev':|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
E:\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||error: ld returned 1 exit status|
||=== Build failed: 21 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Cmdu76

  • Full Member
  • ***
  • Messages: 194
    • Voir le profil
Re : Configuration SFML code block
« Réponse #5 le: Juillet 03, 2016, 01:00:17 am »
Justement tu as fais ce que G. avait dit de ne pas faire :)

Avant tu avais juste lier les sfml-xxx-d sans ajouter les .dll aux côtés de ton éxécutable.

Donc retire le SFML_STATIC et ajoute les, ou alors si tu veux le faire en static il faut que tu mettes : "sfml-xxx-s-d" en Debug et "sfml-xxx-s" en Release

Tutoriel sur CodeBlocks :
Citer
Les options montrées ici vont lier votre application à la version dynamique de SFML, celle qui a besoin des fichiers DLL pour fonctionner. Si vous voulez vous débarrasser de ces DLLs et avoir SFML directement intégrée à votre exécutable, vous devez lier à la version statique. Les bibliothèques statiques de SFML ont le suffixe "-s" : "sfml-xxx-s-d" en Debug et "sfml-xxx-s" en Release.
Dans ce cas, vous devrez aussi définir la macro SFML_STATIC dans les options préprocesseur de votre projet.

G.

  • Hero Member
  • *****
  • Messages: 1593
    • Voir le profil
Re : Configuration SFML code block
« Réponse #6 le: Juillet 03, 2016, 01:26:37 am »
Oui ce que je demandais c'était les erreurs possibles, pas ce qu'il fallait faire. :p

Ça ressemble pas mal à ça : http://en.sfml-dev.org/forums/index.php?topic=14958.0
Est-ce que la version de SFML que tu as téléchargé correspond bien à la version de ton compilateur ?

arzop

  • Newbie
  • *
  • Messages: 7
    • Voir le profil
    • E-mail
Re : Configuration SFML code block
« Réponse #7 le: Juillet 03, 2016, 10:30:43 am »
Bien, j ai tout desinstalle et re installe avec (je crois) les bonnes versions:

GCC 4.8.1 TDM (SJLJ) - 32-bit
https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/Previous/1.1309.0/tdm-gcc-4.8.1.exe/download

J ai lie la biblihoteque static (j ai joint les screenshots au cas ou) mais voila:

||=== Build: Debug in testSFML (compiler: GNU GCC Compiler) ===|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderStates.cpp.obj)||In function `_static_initialization_and_destruction_0':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderStates.cpp|102|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderStates.cpp|102|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderStates.cpp|102|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderStates.cpp|102|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(CircleShape.cpp.obj)||In function `ZN2sf11CircleShapeC2Efj':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\CircleShape.cpp|35|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\CircleShape.cpp|35|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\CircleShape.cpp|37|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\CircleShape.cpp|37|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZN2sf12RenderWindowC2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|35|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|35|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|35|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|35|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZN2sf12RenderWindowC2ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|42|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|42|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|42|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|42|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZN2sf12RenderWindowC2EP6HWND__RKNS_15ContextSettingsE':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|50|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|50|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|50|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|50|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZN2sf12RenderWindowD2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|58|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|58|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|58|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|58|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZNK2sf12RenderWindow7captureEv':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|80|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|80|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|92|undefined reference to `glReadPixels@28'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|95|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderWindow.cpp|95|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZNSt6vectorIhSaIhEEC1EjRKhRKS0_':|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|295|undefined reference to `__gxx_personality_sj0'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|295|undefined reference to `_Unwind_SjLj_Register'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|297|undefined reference to `_Unwind_SjLj_Resume'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|297|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZNSt6vectorIhSaIhEED1Ev':|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|414|undefined reference to `__gxx_personality_sj0'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|414|undefined reference to `_Unwind_SjLj_Register'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|416|undefined reference to `_Unwind_SjLj_Resume'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|416|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZNSt12_Vector_baseIhSaIhEEC2EjRKS0_':|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|134|undefined reference to `__gxx_personality_sj0'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|134|undefined reference to `_Unwind_SjLj_Register'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|135|undefined reference to `_Unwind_SjLj_Resume'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|135|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(RenderWindow.cpp.obj)||In function `ZNSt12_Vector_baseIhSaIhEED2Ev':|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|159|undefined reference to `__gxx_personality_sj0'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|159|undefined reference to `_Unwind_SjLj_Register'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|161|undefined reference to `_Unwind_SjLj_Resume'|
c:\dev\mingw32-tdm481\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|161|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(Shape.cpp.obj)||In function `ZN2sf5ShapeD2Ev':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\Shape.cpp|58|undefined reference to `__gxx_personality_sj0'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\Shape.cpp|58|undefined reference to `_Unwind_SjLj_Register'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\Shape.cpp|58|undefined reference to `_Unwind_SjLj_Resume'|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\Shape.cpp|58|undefined reference to `_Unwind_SjLj_Unregister'|
E:\SFML\lib\libsfml-graphics-s-d.a(Shape.cpp.obj)||In function `ZN2sf5Shape10setTextureEPKNS_7TextureEb':|
D:\sfml-release\_Sources\SFML\src\SFML\Graphics\Shape.cpp|65|undefined reference to `__gxx_personality_sj0'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|


arzop

  • Newbie
  • *
  • Messages: 7
    • Voir le profil
    • E-mail
Re : Configuration SFML code block
« Réponse #8 le: Juillet 03, 2016, 06:27:04 pm »
En telechargeant, le TDM64-GCC-4.8.1, voici ce que j'obtiens:

||=== Build: Debug in testSFML (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lsfml-graphics-s-d|
ld.exe||cannot find -lsfml-window-s-d|
ld.exe||cannot find -lsfml-system-s-d|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

G.

  • Hero Member
  • *****
  • Messages: 1593
    • Voir le profil
Re : Configuration SFML code block
« Réponse #9 le: Juillet 06, 2016, 09:31:05 pm »
Je ne sais pas ce qui ne va pas dans ton avant dernier post.
Mais dans le dernier, c'est surement que le chemin vers la lib n'est plus bon. (capture2 dans ton premier post)

 

anything