2011-12-18 16 views
7
gcc -lGL -lGLU -lglut light.c 
/tmp/ccfuthSi.o: In function `init': 
light.c:(.text+0x72): undefined reference to `glClearColor' 
light.c:(.text+0x7e): undefined reference to `glShadeModel' 
light.c:(.text+0x99): undefined reference to `glMaterialfv' 
light.c:(.text+0xb4): undefined reference to `glMaterialfv' 
light.c:(.text+0xcf): undefined reference to `glLightfv' 
light.c:(.text+0xdb): undefined reference to `glEnable' 
light.c:(.text+0xe7): undefined reference to `glEnable' 
light.c:(.text+0xf3): undefined reference to `glEnable' 
/tmp/ccfuthSi.o: In function `display': 
light.c:(.text+0x107): undefined reference to `glClear' 
light.c:(.text+0x121): undefined reference to `glutSolidSphere' 
light.c:(.text+0x126): undefined reference to `glFlush' 
/tmp/ccfuthSi.o: In function `reshape': 
light.c:(.text+0x150): undefined reference to `glViewport' 
light.c:(.text+0x15c): undefined reference to `glMatrixMode' 
light.c:(.text+0x161): undefined reference to `glLoadIdentity' 
light.c:(.text+0x1bf): undefined reference to `glOrtho' 
light.c:(.text+0x217): undefined reference to `glOrtho' 
light.c:(.text+0x223): undefined reference to `glMatrixMode' 
light.c:(.text+0x228): undefined reference to `glLoadIdentity' 
/tmp/ccfuthSi.o: In function `main': 
light.c:(.text+0x268): undefined reference to `glutInit' 
light.c:(.text+0x274): undefined reference to `glutInitDisplayMode' 
light.c:(.text+0x288): undefined reference to `glutInitWindowSize' 
light.c:(.text+0x29c): undefined reference to `glutInitWindowPosition' 
light.c:(.text+0x2a9): undefined reference to `glutCreateWindow' 
light.c:(.text+0x2ba): undefined reference to `glutDisplayFunc' 
light.c:(.text+0x2c6): undefined reference to `glutReshapeFunc' 
light.c:(.text+0x2d2): undefined reference to `glutKeyboardFunc' 
light.c:(.text+0x2d7): undefined reference to `glutMainLoop' 

लिंक नहीं करता है जैसा कि आप देख सकते हैं, मैं जीसीसी के लिए आवश्यक पैरामीटर पास करता हूं। यह क्यों काम नहीं करता है? लिनक्स मिंट 12.जीसीसी - एलडी ओपनजी

उत्तर

16

यह वास्तव में एक एफएक्यू है (और यहां पूछा गया है और कई बार जवाब दिया गया है)। लिंक करते समय तर्कों का आदेश महत्वपूर्ण है। पुस्तकालयों को अंतिम (और अच्छे क्रम में) जाना चाहिए। आपको

gcc -Wall -g light.c -lGL -lGLU -lglut -o light 
+0

एनबी: ग्लूट से अपरिचित होने के नाते, मुझे पूरी तरह से पुस्तकालयों के आदेश के बारे में निश्चित नहीं होना चाहिए। आपको सही पता लगाना चाहिए! –

+1

साझा लाइब्रेरी सिस्टम के मामले में, इससे कोई फर्क नहीं पड़ता, क्योंकि ग्लूट में पहले से ही इसके सभी प्रतीक हाउसकीपिंग किए गए हैं और आप केवल light.c की संतुष्टि करने की कोशिश कर रहे हैं। –

संबंधित मुद्दे