Problème de link avec glut et CMake
Bonjour,
J'ai un projet qui tourne sous Windows et on m'a demandé de le porter sous Linux tout simplement pour une raison de librairie annexe dont on a besoin et dont le seule licence disponible au labo est sous Linux. Je tiens à préciser que je n'ai jamais vraiment fait de "gros" projet sous Linux avant donc je me tourne vers vous vu que j'ai un problème que je n'arrive pas à résoudre.
Sous WIndows le projet était composé de plusieurs sous projets. J'ai donc décider d'utiliser CMake pour faire la même chose. Disons pour le moment que j'ai un projet A et un projet B qui doit utiliser la librairie statique A. Jusque là pas de problème.
Maintenant mon projet B utilise des fonctions Glut. Pour la compilation je n'ai pas de problème, mais le link ne passe pas.
Voilà les erreurs que j'ai (j'ai coupé la fin car il y a enormément d'erreurs de link du même style) :
Code:
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
| [ 75%] Building CXX object Bvh/CMakeFiles/Bvh.dir/Bvh.o
In file included from /afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Bvh/Bvh.cpp:4:
/afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Glut/include/GL/glut.h:19:1: warning: "APIENTRY" redefined
In file included from /afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Glut/include/GL/glut.h:14,
from /afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Bvh/Bvh.cpp:4:
/usr/include/GL/gl.h:104:1: warning: this is the location of the previous definition
[100%] Building CXX object Bvh/CMakeFiles/Bvh.dir/Joint.o
Linking CXX static library libBvh.a
[100%] Built target Bvh
[gossip]v1lhoyet: cd ..
[gossip]v1lhoyet: make
[ 40%] Built target Mathematics
[ 80%] Built target Bvh
Scanning dependencies of target Test
[100%] Building CXX object Tests/CMakeFiles/Test.dir/test.o
/afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Tests/test.cpp: In function â:
/afs/inf.ed.ac.uk/user/v/v1lhoyet/Motion/Tests/test.cpp:9: warning: converting to â from â
Linking CXX executable Test
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libglut.a(libglut_la-freeglut_init.o): In function `glutInit':
(.text+0x369): undefined reference to `glXQueryExtension'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libglut.a(libglut_la-freeglut_main.o): In function `fghcbDisplayWindow':
(.text+0x198): undefined reference to `glViewport'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libglut.a(libglut_la-freeglut_main.o): In function `glutMainLoopEvent':
(.text+0xa95): undefined reference to `glViewport'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libglut.a(libglut_la-freeglut_menu.o): In function `fgDisplayMenu': |
Et au passage voici mon CMakeLists.txt pour le projet B
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # Make sure the compiler can find include files from our libraries.
include_directories (${MOTION_SOURCE_DIR}/Mathematics)
include_directories (${MOTION_SOURCE_DIR}/Glut/include/GL)
# Make sure the linker can find the libraries once it is built.
link_directories (${MOTION_BINARY_DIR}/Mathematics)
link_directories (${MOTION_BINARY_DIR}/Glut/lib/glut/)
link_directories (/usr/lib/X11/)
# Create the "Bvh" library.
add_library (Bvh Bvh.cpp Joint.cpp)
# Link the executable to the libraries.
target_link_libraries (Bvh Mathematics libglut.a) |
Est-ce que quelqu'un peut m'aider ? J'ai cru comprendre que ça pourrait venir du fait qu'il faille linker avec la librairie X11, mais je n'arrive pas à m'en dépaitouiller ...
Merci d'avance