LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-14-2010, 06:39 AM   #1
stefanolima
Member
 
Registered: Jul 2008
Location: Dar-es-Salaam
Distribution: Fedora,CentOS,Ubuntu
Posts: 60

Rep: Reputation: 15
OpenGL/Glut/Codeblock : compile error - - undefined reference to...


Hi!

I'm learning graphics programming on Open GL/Glut using codeblock. During compilation I get errors as illustrated below

C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:35: undefined reference to `_glutInit@8'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:36: undefined reference to `_glutInitDisplayMode@4'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:37: undefined reference to `_glutInitWindowSize@8'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:38: undefined reference to `_glutInitWindowPosition@8'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:39: undefined reference to `_glutCreateWindow@4'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:40: undefined reference to `_glutDisplayFunc@4'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:41: undefined reference to `_glutKeyboardFunc@4'
C:/Program Files/CodeBlocks/projects/opengl1/keyboard.cpp:42: undefined reference to `_glutMainLoop@0'

What could be the cause?

The libraries I use are

#include <GL/gl.h>
#include <iostream>
#include <cstdlib>
#include <GL/glut.h>
#include <stdlib.h>

My glut.h is on folder include/GL

how to know more libraries needed for openGL/glut?

Cheers,
Stefano
 
Old 01-14-2010, 08:19 AM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Hey,

"undefined reference" error is emitted by the linker, not the compiler. I guess you missed to specify the opengl/glut library for linking, e.g.

# gcc <usual_options> -lopengl

or whatever the name of the library is. The -l Option implies the library name to begin with lib*. In the case the OpenGL does not start with lib*, you could use the following syntax:

# gcc <usual_options> -l:<library_name>

For the case, the solutions above don't help either, you should check that the linker really knows where to search for the libraries (-L option). Maybe, you need to use something from pkg-config ...

Hope that helps,
- Andi -
 
Old 01-14-2010, 08:53 AM   #3
r.stiltskin
Member
 
Registered: Oct 2003
Location: USA
Distribution: Xubuntu, Arch
Posts: 231

Rep: Reputation: 31
Are you building it in CodeBlocks or using command line? If command line, you need -lglut as part of the command.

Are you using the glut example provided by CodeBlocks' new project wizard?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gtkboard compile error: undefined reference to `FT_GlyphSlot_Embolden' rextor Linux - Games 2 11-18-2011 05:24 PM
compile error: undefined reference to std::basic_ostream ron7000 Programming 5 09-17-2008 09:13 AM
undefined reference to `g_assertion_message_expr when trying to compile jpilot nowshining Linux - Software 1 04-28-2008 11:37 PM
Compile QT get Undefined reference jordban Linux - General 14 01-15-2005 06:58 PM
ncurses compile error: "undefined reference" Mr. Eek Linux From Scratch 1 05-12-2003 04:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration