Partage
  • Partager sur Facebook
  • Partager sur Twitter

[SFML][Vi$ta] Aucune erreur au compilateur et Vista ne veut pas le lancer le prog'

Mais... Mais... Où est l'erreur ?!

Sujet résolu
    4 mars 2008 à 17:49:13

    r />
    Voilà tout, et Vi$ta m'affiche :

    Buuuuuuuuuug

    Ah oui aussi je pense qu'il y a eu une faute de segmentation (C'est le débugger qui m'a dit ça moi je n'ai rien dit :-°:p )

    EDIT: Si quelqu'un de vous avait essayé de compiler le projet, ce serait gentil de me dire si vous avez pu faire executer le prog' sur Vista ou autre ;)

    Merci de votre aide :)

    @+span class="co2">#include <fstream>
    #include <string>
    #include "main.h"
    #include "classes.h"
    using namespace std;
    Snake::Snake()
    {
            Fichiers fichier;
            fichier.chargerMap();
            m_longeurSnake = 3;
            m_vie = 3;
    }
    Snake::~Snake()
    {
    }
    unsigned int Snake::getVie() const
    {
        return m_vie;
    }
    unsigned int Snake::getLongeurSnake() const
    {
        return m_longeurSnake;
    }
    Fichiers::Fichiers()
    {
        m_chemin = "data/niveaux/niveaux.lvl";
    }
    Fichiers::Fichiers(string chemin) : m_chemin(chemin)
    {
    }
    Fichiers::~Fichiers()
    {
    }
    bool Fichiers::chargerMap(string chemin)
    {
        char fichier[NB_BLOCS_LARGEUR] = {0};
        if(m_chemin != "")
        {
            if(chemin == "")
            {
                ifstream map(m_chemin.c_str(), ios::in);
                if(map != NULL)
                {
                    map >> fichier;
                    for(int i = 0; i < NB_BLOCS_HAUTEUR; ++i)
                    {
                        for(int j = 0; j < NB_BLOCS_LARGEUR; ++j)
                        {
                            switch(fichier[(i * NB_BLOCS_HAUTEUR) + j])
                            {
                                case '0':
                                m_map[i][j] = VIDE;
                                    break;
                                case '1':
                                m_map[i][j] = MUR;
                                    break;
                                case '2':
                                m_map[i][j] = QUEUE;
                                    break;
                                case '3':
                                m_map[i][j] = TETE;
                                    break;
                                case '4':
                                m_map[i][j] = POMME;
                                    break;
                            }
                        }
                    }
                    return true;
                }
                else
                {
                    string erreur = "Impossible de charger : ";
                    erreur += m_chemin;
                    Fichiers::ecrireErreur(erreur);
                    return false;
                }
            }
        }
        else
        {
            if(chemin != "")
            {
                ifstream map(chemin.c_str(), ios::in);
                if(!map.fail())
                {
                    map >> fichier;
                    for(int i = 0; i < NB_BLOCS_HAUTEUR; ++i)
                    {
                        for(int j = 0; j < NB_BLOCS_LARGEUR; ++j)
                        {
                            switch(fichier[(i * NB_BLOCS_HAUTEUR) + j])
                            {
                                case '0':
                                m_map[i][j] = VIDE;
                                    break;
                                case '1':
                                m_map[i][j] = MUR;
                                    break;
                                case '2':
                                m_map[i][j] = QUEUE;
                                    break;
                                case '3':
                                m_map[i][j] = TETE;
                                    break;
                                case '4':
                                m_map[i][j] = POMME;
                                    break;
                            }
                        }
                    }
                    return true;
                }
                else
                {
                    string erreur = "Impossible de charger : ";
                    erreur += chemin;
                    Fichiers::ecrireErreur(erreur);
                    return false;
                }
            }
        }
    }
    void Fichiers::ecrireErreur(std::string erreur)
    {
        if(erreur != "")
        {
        cerr << erreur << endl;
        }
        else
        {
            cerr << "Log d'erreurs de Snake V.1 : (Généré automatiquement)" << endl;
        }
    }
    bool Snake::jouer(sf::RenderWindow * Ecran)
    {
    }


    classes.h :

    1. #include <SFML/Graphics.hpp>
    2. #include <string>
    3. #include "main.h"
    4. class Snake
    5. {
    6.     public: /* Fonctions accessibles depuis l'extérieur */
    7.     Snake();
    8.     ~Snake();
    9.     bool jouer(sf::RenderWindow* Ecran);
    10.     bool deplacerJoueur();
    11.     unsigned int getLongeurSnake() const;
    12.     unsigned int getVie() const;
    13.     protected: /* Les Protected's */
    14.     int m_map[NB_BLOCS_HAUTEUR][NB_BLOCS_LARGEUR];
    15.     private: /* Les privates */
    16.     unsigned int m_longeurSnake;
    17.     unsigned int m_vie;
    18. };
    19. class Fichiers : public Snake
    20. {
    21.     public:
    22.     Fichiers();
    23.     Fichiers(std::string chemin);
    24.     ~Fichiers();
    25.     bool chargerMap(std::string chemin = "");
    26.     bool sauvegarderMap(std::string chemin = "");
    27.     static void ecrireErreur(std::string erreur = "");
    28.     private:
    29.     std::string m_chemin;
    30. };


    main.cpp :

    1. #include <SFML/System.hpp>
    2. #include <SFML/Graphics.hpp>
    3. #include <iostream>
    4. #include <string>
    5. #include "main.h"
    6. #include "classes.h"
    7. using namespace std;
    8. int main()
    9. {
    10.     /* Instances des objets */
    11.     Fichiers::ecrireErreur();
    12.     Snake snake;
    13.     sf::RenderWindow Ecran(sf::VideoMode(HAUTEUR_FENETRE, LARGEUR_FENETRE, 32), "Snake V.1");
    14.     sf::Event Event;
    15.     bool Running = true;
    16.     Ecran.SetBackgroundColor(sf::Color(255, 255, 255));
    17.     /* -------------------------------- */
    18.     /* -------------------------------- */
    19.     Ecran.SetFramerateLimit(35);
    20.     Ecran.UseVerticalSync(true);
    21.     while (Running) /* Boucle Principale */
    22.     {
    23.         while (Ecran.GetEvent(Event))
    24.         {
    25.             switch (Event.Type)
    26.             {
    27.                 case sf::Event::Closed : /* Si on cliqué sur le bouton Fermer */
    28.                 Running = false;
    29.                     break;
    30.                 case sf::Event::KeyPressed : /* Si une touche a été pressée */
    31.                 switch (Event.Key.Code)
    32.                 {
    33.                     case sf::Key::Escape : /* Si on a appuyé sur Echap */
    34.                     Running = false;
    35.                         break;
    36.                     case sf::Key::Numpad1 :
    37.                     snake.jouer(&Ecran);
    38.                         break;
    39.                 }
    40.                     break;
    41.             }
    42.         }
    43.         Ecran.Display();
    44.     }
    45.     return 0;
    46. }


    main.h :

    1. /* Snake */
    2. #ifndef DEF_CONSTANTES
    3. #define DEF_CONSTANTES
    4.     #define TAILLE_BLOC  15
    5.     #define NB_BLOCS_HAUTEUR 20
    6.     #define NB_BLOCS_LARGEUR 20
    7.     #define HAUTEUR_FENETRE (TAILLE_BLOC * NB_BLOCS_HAUTEUR)
    8.     #define LARGEUR_FENETRE (TAILLE_BLOC * NB_BLOCS_HAUTEUR)
    9.     enum { HAUT, BAS, DROITE, GAUCHE };
    10.     enum { VIDE, TETE, QUEUE, POMME, MUR };
    11. #endif
    • Partager sur Facebook
    • Partager sur Twitter
      4 mars 2008 à 18:24:54

      Avant toute chose: as-tu bien incorporé les dlls?
      • Partager sur Facebook
      • Partager sur Twitter
        4 mars 2008 à 18:30:33

        J'ai mis le projet en Static je ne trouve pas les DLL (Quels sont les DLLs nécessaires ??)
        • Partager sur Facebook
        • Partager sur Twitter
          4 mars 2008 à 19:05:34

          Dans ce cas, c'est sûrement pas dû aux DLLs :p ... Essaie de localiser le problème à coup de débogueur en placant des points d'arrêt un peu partout.
          • Partager sur Facebook
          • Partager sur Twitter
            4 mars 2008 à 19:06:56

            Comment on fait les break-points ? :s Désolé mais je n'y connais presque rien
            • Partager sur Facebook
            • Partager sur Twitter
              4 mars 2008 à 21:17:37

              Si tu as Code::Blocks avec MinGW il faut d'abord que tu installes gdb. Ensuite tu compiles en mode debug et tu ajoutes des breakpoints via le menu debug->add new break point (je crois) (ajouté à la ligne actuelle du curseur d'insertion de texte), ensuite tu fait debug->start et tu bouges au gré des lignes avec next line.

              Si tu es sous VS, tu compiles en debug, tu ajoutes les breakpoints où tu le souhaite avec un truc similaire et tu executes avec debug->run with debugger (je crois)

              J'ai pas les IDE sous la main, main le principe est là.

              Tu pourras facilement comprendre si ton problème est dû à une abscence de dll (ce sera précisé), une erreur de segmentation (pointeur foireux) etc...
              • Partager sur Facebook
              • Partager sur Twitter
                5 mars 2008 à 8:30:03

                Je suis sous Code::Blocks 8.02 et je n'ai pas de Target : Debug mais j'ai Release

                GDB quand je l'ouvre, Il y a une fenêtre qui me dit que le programme a voulu faire quelque chose d'illégal o_O

                Upp Upp Uuuuuuuuuuuuuupp ^^

                EDIT: J'ai remarqué que si j'enlève les classes du projet, eh bien la fenêtre s'affiche normalement ...

                En mode Debug, il me dit qu'il y a des erreurs de segmentation (2 fois à peu près) je fais quoi ????? :o

                1. Building to ensure sources are up-to-date
                2. Build succeeded
                3. Selecting target:
                4. Release
                5. Adding source dir: C:\Users\admin\Bureau\Projet Mehdi C-C++\OpenGL\Mario Orienté Objet\
                6. Adding source dir: C:\Users\admin\Bureau\Projet Mehdi C-C++\OpenGL\
                7. Changing directory to: C:/Users/admin/Bureau/PROJET~1/OpenGL/MARIOO~2/bin/Release
                8. Adding file: bin\Release\Snake.exe
                9. Starting debugger:
                10. done
                11. Registered new type: wxString
                12. Registered new type: STL String
                13. Registered new type: STL Vector
                14. Setting breakpoints
                15. (no debugging symbols found)
                16. Debugger name and version: GNU gdb 6.7.50.20071127
                17. No symbol table is loaded.  Use the "file" command.
                18. No symbol table is loaded.  Use the "file" command.
                19. No symbol table is loaded.  Use the "file" command.
                20. No symbol table is loaded.  Use the "file" command.
                21. No symbol table is loaded.  Use the "file" command.
                22. No symbol table is loaded.  Use the "file" command.
                23. No symbol table is loaded.  Use the "file" command.
                24. No symbol table is loaded.  Use the "file" command.
                25. No symbol table is loaded.  Use the "file" command.
                26. No symbol table is loaded.  Use the "file" command.
                27. No symbol table is loaded.  Use the "file" command.
                28. No symbol table is loaded.  Use the "file" command.
                29. No symbol table is loaded.  Use the "file" command.
                30. No symbol table is loaded.  Use the "file" command.
                31. No symbol table is loaded.  Use the "file" command.
                32. No symbol table is loaded.  Use the "file" command.
                33. No symbol table is loaded.  Use the "file" command.
                34. No symbol table is loaded.  Use the "file" command.
                35. No symbol table is loaded.  Use the "file" command.
                36. No symbol table is loaded.  Use the "file" command.
                37. No symbol table is loaded.  Use the "file" command.
                38. No symbol table is loaded.  Use the "file" command.
                39. Child process PID: 5480
                40. (no debugging symbols found)
                41. (no debugging symbols found)
                42. (no debugging symbols found)
                43. (no debugging symbols found)
                44. (no debugging symbols found)
                45. (no debugging symbols found)
                46. (no debugging symbols found)
                47. (no debugging symbols found)
                48. (no debugging symbols found)
                49. (no debugging symbols found)
                50. (no debugging symbols found)
                51. (no debugging symbols found)
                52. (no debugging symbols found)
                53. (no debugging symbols found)
                54. (no debugging symbols found)
                55. (no debugging symbols found)
                56. (no debugging symbols found)
                57. (no debugging symbols found)
                58. (no debugging symbols found)
                59. (no debugging symbols found)
                60. (no debugging symbols found)
                61. (no debugging symbols found)
                62. (no debugging symbols found)
                63. (no debugging symbols found)
                64. (no debugging symbols found)
                65. (no debugging symbols found)
                66. (no debugging symbols found)
                67. (no debugging symbols found)
                68. (no debugging symbols found)
                69. (no debugging symbols found)
                70. (no debugging symbols found)
                71. Program received signal SIGSEGV, Segmentation fault.
                72. In ?? () ()
                73. In ntdll!LdrEnumerateLoadedModules () (C:\Windows\system32\ntdll.dll)
                74. In ntdll!LdrEnumerateLoadedModules () (C:\Windows\system32\ntdll.dll)
                75. In ntdll!LdrEnumerateLoadedModules () (C:\Windows\system32\ntdll.dll)
                76. In ntdll!LdrEnumerateLoadedModules () (C:\Windows\system32\ntdll.dll)
                77. In ntdll!LdrEnumerateLoadedModules () (C:\Windows\system32\ntdll.dll)
                78. Program received signal SIGSEGV, Segmentation fault.
                79. In ?? () ()
                • Partager sur Facebook
                • Partager sur Twitter
                  6 mars 2008 à 14:35:52

                  Up !!!!!!!!!!!!!!! Il n'y a plus personne tout à coup ?! :(


                  EDIT:
                  J'ai trouvé quelque chose qui pourrait servir : Si j'enlève l'objet Snake snake; tout marche et si je le remets ça bloque ! !!!
                  • Partager sur Facebook
                  • Partager sur Twitter
                  Anonyme
                    6 mars 2008 à 16:24:57

                    Donc ça vient de snake. Trouve où exactement.
                    • Partager sur Facebook
                    • Partager sur Twitter
                      6 mars 2008 à 16:34:35

                      Oulah!
                      Le constructeur de Snake appelle le constructeur de Fichier qui appelle le constructeur de Snake car il hérite de Snake mais ce constructeur appelle le constructeur de Fichier qui .....
                      • Partager sur Facebook
                      • Partager sur Twitter
                        6 mars 2008 à 16:50:11

                        Je vois pas où est exactement l'erreur :o

                        EDIT: Waaaaaaaaaaaah ! Merci les gars ! j'ai enfin pu faire marcher le prog' !! Merci mille fois !

                        (Comme a dit M@theo21 : (La POO, ça peut parfois donner mal à la tête j'avais oublié de vous prévenir :p ) )
                        • Partager sur Facebook
                        • Partager sur Twitter

                        [SFML][Vi$ta] Aucune erreur au compilateur et Vista ne veut pas le lancer le prog'

                        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                        • Editeur
                        • Markdown