IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Discussion :

problem d'edition de lien -lQtGui avec Qt en utilisant Coin


Sujet :

Qt

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Tunisie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 141
    Points : 59
    Points
    59
    Par défaut problem d'edition de lien -lQtGui avec Qt en utilisant Coin
    Bonjour,

    je travaille avec QT et Coin3d (Inventor) sous linux et j'essaye de faire une application qui reuni les deux,et enfait je compile les deux en ligne de commande en utilsant g++

    quand je compile ce code QT :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    QApplication app(argc,argv);
    QPushButton quit("Quit"); 
    quit.resize(75,30);
    quit.setFont(QFont("Times",18,QFont::Bold));
    QObject :: connect(&quit,SIGNAL(cliked()),&app,SLOT(quit()));
    quit.show();
    return app.exec();
    j'utilise la ligne de commande suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++  -g -o test -I /usr/lib64/qt4/include -L /usr/lib64/qt4/lib64 -lQtGui test.cc
    et ca marche parfaitement,

    quand je compile le code Coin suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
     #include    <Inventor/SoDB.h>
               #include    <Inventor/Qt/SoQt.h>
               #include    <Inventor/Qt/editors/SoQtMaterialEditor.h>
               #include    <Inventor/Qt/SoQtRenderArea.h>
               #include    <Inventor/nodes/SoDirectionalLight.h>
               #include    <Inventor/nodes/SoMaterial.h>
               #include    <Inventor/nodes/SoPerspectiveCamera.h>
               #include    <Inventor/nodes/SoSeparator.h>
              #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
               main(int , char **argv)
               {
                   // Initialize Inventor and Qt
    	     QWidget *myWindow = SoQt::init(argv[0]);
     
                   // Build the render area in the applications main window
                   SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);
                   myRenderArea->setSize(SbVec2s(400, 200));
                   // Build the material editor in its own window
                   SoQtMaterialEditor *myEditor = new SoQtMaterialEditor;
                   // Create a scene graph
                   SoSeparator *root = new SoSeparator;
                   SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
                   SoMaterial *myMaterial = new SoMaterial;
                   root->ref();
                   myCamera->position.setValue(0.212482, 0.881014, 2.5);
                   myCamera->heightAngle = M_PI/4;
                   root->addChild(myCamera);
                   root->addChild(new SoDirectionalLight);
                   root->addChild(myMaterial);
                   // Read the geometry from a file and add to the scene
                   SoInput myInput;
                   if (!myInput.openFile("Barcelona.iv"))
         exit (1);
      SoSeparator *geomObject = SoDB::readAll(&myInput);
     
      if (geomObject == NULL)
         exit (1);
      root->addChild(geomObject);
    SoQtExaminerViewer * myViewer = new SoQtExaminerViewer(myWindow);
      // Set the scene graph
      myViewer->setSceneGraph(root);
      // Attach material editor to the material
      myEditor->attach(myMaterial);
      // Show the application window and the material editor
       myViewer->setTitle("Attach Editor");
       myViewer->show();
      SoQt::show(myWindow);
      myEditor->show();
      // Loop forever
      SoQt::mainLoop();
    }
    avec la ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++  -o test -I /usr/lib64/qt4/include/ -I /usr/lib64/qt4/include/Qt/ -I /usr/include/Coin2/ -L /usr/lib/Coin2/ test.cc -lCoin -lSoQt
    ca marche aussi parfaitement..
    mais j'essaye de combiner les deux :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    #include <qapplication.h>
    #include<qfont.h>
    #include<qpushbutton.h>
    #include <QtGui/QApplication>
    #include<QtGui/QFont>
    #include<QtGui/QPushButton>
    #include<Inventor/SoDB.h>
    #include    <Inventor/Qt/SoQt.h>
    #include    <Inventor/Qt/editors/SoQtMaterialEditor.h>
    #include    <Inventor/Qt/SoQtRenderArea.h>
    #include    <Inventor/nodes/SoDirectionalLight.h>
    #include    <Inventor/nodes/SoMaterial.h>
    #include    <Inventor/nodes/SoPerspectiveCamera.h>
    #include    <Inventor/nodes/SoSeparator.h>
    #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
    main(int argc ,char **argd, char *argv[])
               {
     
    QApplication app(argc,argv);
    QPushButton quit("Quit"); 
    quit.resize(75,30);
    quit.setFont(QFont("Times",18,QFont::Bold));
    QObject :: connect(&quit,SIGNAL(cliked()),&app,SLOT(quit()));
    quit.show();
    return app.exec(); 
     
                   // Initialize Inventor and Qt
                   QWidget *myWindow = SoQt::init(argd[0]);
     
                   // Build the render area in the applications main window
                   SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);
                   myRenderArea->setSize(SbVec2s(400, 200));
                   // Build the material editor in its own window
                   SoQtMaterialEditor *myEditor = new SoQtMaterialEditor;
                   // Create a scene graph
                   SoSeparator *root = new SoSeparator;
                   SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
                   SoMaterial *myMaterial = new SoMaterial;
                   root->ref();
                   myCamera->position.setValue(0.212482, 0.881014, 2.5);
                   myCamera->heightAngle = M_PI/4;
                   root->addChild(myCamera);
                   root->addChild(new SoDirectionalLight);
                   root->addChild(myMaterial);
                   // Read the geometry from a file and add to the scene
                   SoInput myInput;
                   if (!myInput.openFile("Barcelona.iv"))
         exit (1);
      SoSeparator *geomObject = SoDB::readAll(&myInput);
     
      if (geomObject == NULL)
         exit (1);
      root->addChild(geomObject);
    SoQtExaminerViewer * myViewer = new SoQtExaminerViewer(myWindow);
      // Set the scene graph
      myViewer->setSceneGraph(root);
      // Attach material editor to the material
      myEditor->attach(myMaterial);
      // Show the application window and the material editor
       myViewer->setTitle("Attach Editor");
       myViewer->show();
      SoQt::show(myWindow);
      myEditor->show();
      // Loop forever
      SoQt::mainLoop();
    }
    avec la ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++  -o tes -I /usr/lib64/qt4/include/ -I /usr/lib64/qt4/include/Qt/ -I /usr/include/Coin2/ -L /usr/lib/Coin2/ -L /usr/lib64/qt4/lib64/ test.cc -lCoin -lSoQt -lQtGui
    il me sort "incident de segmentation"
    et j'ai essayé de cerner un peu le problem,il vient apparement de -lQtGui,mais je dois l'inculre sinon l'edition de liens ne se passera pas bien..
    quelqu'un pourrait m'aider la dessus ?

  2. #2
    Membre averti
    Avatar de Niak74
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    271
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Juin 2007
    Messages : 271
    Points : 333
    Points
    333
    Par défaut
    Pourquoi n'utilises tu pas qmake?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Tunisie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 141
    Points : 59
    Points
    59
    Par défaut
    parcque je veux compiler du code coin aussi(c++) et je suis pas sure que qmake fera l'affaire,mais sinon si c'etait avec qmake,la derniere commande donnerait quoi ?

  4. #4
    Membre averti
    Avatar de Niak74
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    271
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Juin 2007
    Messages : 271
    Points : 333
    Points
    333
    Par défaut
    Coin semble être une librairie compilée à part, vu tes appels à g++. Sépare Coin et ton applications en 2 projets distinct.

    Pour ton application, fais un qmake -project dans le répertoire de tes sources (de type Qt). Ceci aura pour effet de générer un fichier .pro.

    Dans celui-ci, ajoute :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    LIBS += -L/usr/lib/Coin2/
    LIBS += -lCoin
    INCLUDEPATH += /usr/include/Coin2/
    Fais ensuite un qmake (génère le makefile du projet) et un make pour compiler.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Tunisie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 141
    Points : 59
    Points
    59
    Par défaut
    Citation Envoyé par Niak74 Voir le message
    Coin semble être une librairie compilée à part, vu tes appels à g++. Sépare Coin et ton applications en 2 projets distinct.

    Pour ton application, fais un qmake -project dans le répertoire de tes sources (de type Qt). Ceci aura pour effet de générer un fichier .pro.

    Dans celui-ci, ajoute :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    LIBS += -L/usr/lib/Coin2/
    LIBS += -lCoin
    INCLUDEPATH += /usr/include/Coin2/
    Fais ensuite un qmake (génère le makefile du projet) et un make pour compiler.
    je laisse mon code comme il est ? "mixant les deux" pour moi les deux sont du c++ donc,je peux bien les melanger je comprends pas pourquoi ca foire.
    sinon tu veux dire quoi exactement par "Sépare Coin et ton applications en 2 projets distinct." ?

  6. #6
    Membre averti
    Avatar de Niak74
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    271
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Juin 2007
    Messages : 271
    Points : 333
    Points
    333
    Par défaut
    Une seconde, je viens de tilter que c'est une erreur de segmentation que tu as. C'est donc au moment ou tu run ton application que ça plante, non?

    Je pense que l'erreur vient du code, pas de la compil.

    Par exemple : quand tu écris return app.exec(); ceci sous entend que ton application se terminera à cette ligne. Tout ce qui suit ne sera jamais exécuté !

    A quoi correspondent les objets de préfixe So ?

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Tunisie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 141
    Points : 59
    Points
    59
    Par défaut
    oui au run
    enfait,chaque code à part marche bien.
    les deux réunis,ca plante,et j'ai l"impression que c'est à cause de lQtGui..
    enfin,j'ai essayé de changer à chaque fois la ligne de commande et donc apparement c'est à cause de lQtGui.

  8. #8
    Membre averti
    Avatar de Niak74
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    271
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Juin 2007
    Messages : 271
    Points : 333
    Points
    333
    Par défaut
    Si tu parviens à compiler, je ne vois pas pourquoi le problème viendrait d'une lib en particulier.

    Si tu plante avec un seg fault, c'est une erreur de codage.

    Reprenons ton code, et les bases de la programmation avec Qt. Ton application Qt se traduit par la création d'un objet QApplication et commence à l'instant même où tu fais un QApplication::exec(). Ton programme de manière générale s'arrêtera lorsque ton main rencontrera la clause return.

    Comprends donc bien que si tu écris return app.exec(); dans ton main, ton application se terminera à cette ligne, tout ce qui suit ne sera pas pris en compte !

    Je te demande à quoi correspondent les objets So pour mieux comprendre ce que tu tentes de faire.
    Quoi qu'il en soit, ton code (l'intégration de ton deuxième bout de code au premier) doit se placer entre la ligne
    QApplication app(argc,argv);
    et la ligne
    return app.exec();

    Ta première appli ne fait qu'afficher un bouton qui quitte l'application. La seconde parait déjà plus complexe. Que cherches tu à faire quand tu fusionnes ces deux morceaux de code? Ajouter un bouton pour quitter ton appli?
    Il me faut plus de détails quant à ce que tu souhaites faire (sans parler du code en détail) afin que je puisse te dire si ta conception tient la route. Pour le moment, tout ça me parait très confus.

Discussions similaires

  1. probleme edition de liens
    Par peace_info dans le forum C++
    Réponses: 5
    Dernier message: 14/02/2007, 13h29
  2. Template + probleme à l'édition des liens
    Par ExSter dans le forum Langage
    Réponses: 11
    Dernier message: 07/12/2006, 23h13
  3. probleme d'edition groupe avec quickreport
    Par daylight dans le forum Bases de données
    Réponses: 1
    Dernier message: 18/08/2006, 12h36
  4. Problème d'édition des liens
    Par keyra dans le forum C
    Réponses: 9
    Dernier message: 30/04/2006, 12h48
  5. Réponses: 11
    Dernier message: 20/01/2006, 12h35

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo