LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-23-2005, 05:59 AM   #1
Xerop
Member
 
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Rep: Reputation: 15
I can't get this to compile!


I have been trying for days to compile this code and I always get some sort of undefiened reference error and cannot compile as a result. I would like someone to compile the follwing code and send me the project if it compiles.

Code:
#include <gl/gl.h>
#include <glut.h>


void RenderScene();
void SetupRC();
void RenderScene(void)
{
    glClear (GL_COLOR_BUFFER_BIT);
    glFlush();
}
void SetupRC(void)
{
    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
}

int main(void)
{
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
   glutCreateWindow("Simple");
   glutDisplayFunc(RenderScene);
   SetupRC();
   glutMainLoop();
   
   return 0;
}
This project uses the gl,glu,glut libraries I am don't thing you need windows.h all this code does is bring up a window from the console.
Here is a link to the glut libraries (don't want to slow down this server) .
click here for glut libraries (win32)

Renderscene is called by glut main loop. Notice I passed that to one of the glut functions.

I am using code blocks as an IDE and minGW as a compiler.

THIS CODE IS OS NUETRAL! AS LONG AS YOU HAVE THE LINUX GLUT LIBRARY.
ALL IT DOES IS OPEN A BLANK WINDOW!

Last edited by Xerop; 02-23-2005 at 06:01 AM.
 
Old 02-23-2005, 06:04 AM   #2
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
Undefined references is a linking failure. If you get as far as the linking stage (which in your case fails), the program did compile without errors. You should have posted the exact error message concering the undefiend references the linker is outputting. What you need to do is to tell linker which libraries you are using and where those libraries can be found if they are located in directory that is not normally checked by the linker.
 
Old 02-23-2005, 06:25 AM   #3
Xerop
Member
 
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Original Poster
Rep: Reputation: 15
Ok sorry for not posting the errors, I was having problems linking to the glut libraries and I just got passed those now I am recieving what seems to be internal library link errors which were not there until the glut problems disapeared. I think it is probably my fault and I probably added an extra argument somewhere I'll look today. Here are the new errors I am recieveing:
Code:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/libgcc.a(__main.o)(.text+0x4f): undefined reference to `__EH_FRAME_BEGIN__'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/libgcc.a(__main.o)(.text+0x73): undefined reference to `__EH_FRAME_BEGIN__'
collect2: ld returned 1 exit status

Last edited by Xerop; 02-23-2005 at 06:26 AM.
 
Old 02-23-2005, 07:40 AM   #4
hiteshmaisheri
Member
 
Registered: Nov 2003
Location: Kerala, India
Distribution: Red Hat, Knoppix, Mandrake, FreeBSD
Posts: 231

Rep: Reputation: 30
Here the problem seems that the library path is not set and there is a linking error coming up in your case. Just check some way to get through the library path set in windows. I don't know windows, but in linux just set the LD_LIBRARY_PATH variable with path where the glut library resides.
This should work..
Hitesh
 
Old 02-23-2005, 05:58 PM   #5
Xerop
Member
 
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Original Poster
Rep: Reputation: 15
Thank you very much for your help I think that the problem was in the arguments that I passed to the linker. I remade the project and only included the libraries that I needed and no other and everything went smooth.

These are the libraries I included:
glut32, opengl32
These are the arguments sent to the linker
-lglut32 -lopengl32
Now all the arguments in caps so there is no confusion as to what I passed use the small ones if you plan to use them.
-LGLUT32 -LOPENGL32
and that is a dash

I had to clarify for other noobs that may come and read this post!!!
 
Old 02-25-2005, 02:51 AM   #6
hiteshmaisheri
Member
 
Registered: Nov 2003
Location: Kerala, India
Distribution: Red Hat, Knoppix, Mandrake, FreeBSD
Posts: 231

Rep: Reputation: 30
Kewl.. That seems interesting ..
 
Old 02-25-2005, 07:19 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Also, I think you'll find it makes a difference
in what order you link.
The linker only scans once,
so if you link say
A_lib A_lib_user

it will work, but

A_lib_user A_lib

the A_lib_user will have missing refs as they come later.
The linker doesn't "look back".
 
  


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
ntop compile/post-compile problem? tjb Linux - Software 3 12-28-2004 04:22 PM
What does 'compile' mean? Iain1974 Linux - Newbie 15 08-25-2004 08:38 PM
c/c++ compile zdos Linux - Software 2 05-16-2004 03:22 PM
how to compile x for use on another pc??? markkreuzz Red Hat 1 03-03-2004 10:06 AM
compile jakublgz Programming 8 09-05-2002 05:30 AM

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

All times are GMT -5. The time now is 08:56 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