Jump to content

  • Log In with Google      Sign In   
  • Create Account

Library linking with Eclipse CDT


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 s33d   Members   -  Reputation: 120

Like
0Likes
Like

Posted 23 August 2012 - 09:51 AM

So I've got the SDK working and I'm trying to draw the basic triangle.
#include <gl/glut.h>
void drawSub(void){
//color, dimensions, type
glColor3f(0.0,0.0,0.0);
//vertex, dimensions, type
glVertex3f(-0.5,-0.5,-3.0);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,-0.5,-3.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(0.5,0.5,-3.0);
}
void sSimResh(int x, int y){
if (y == 0 || x == 0) return;  //Nothing is visible then, so return
  //Set a new projection matrix
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  //Angle of view:40 degrees
  //Near clipping plane distance: 0.5
  //Far clipping plane distance: 20.0
  gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
  glMatrixMode(GL_MODELVIEW);
  glViewport(0,0,x,y);  //Use the whole window for rendering
}
void sSimDisp(void){
//clear the color buffer
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
//start drawing stuff
glBegin(GL_POLYGON);
drawSub();
//close rendering stuff
glEnd();
glFlush();
}
int main(int argc, char **argv) {
//initialize GLUT
glutInit(&argc, argv);
//display mode: color index/RGB, 1x/2x buffering
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
//window size
glutInitWindowSize(300,400);
glutCreateWindow("Main Window");
//assign a clear color (R,G,B,alpha)
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//required functions
glutDisplayFunc(sSimDisp);
glutReshapeFunc(sSimResh);
//let GLUT do things
glutMainLoop();
//loop forever
return 0;
}

All fine and good. In the linker section of the project, I have (under -l): glu32, user32, freeglut and opengl32. Eclipse doesn't tell me it's having any problems finding said libraries, so I assumed I was good to roll (includes checked out fine too). Despite this, i'm getting linker errors (undefined reference to `_imp__glutMainLoop@0' etc).

I know my choice of IDE is less than ideal, but I use it for everything else from Java to Python, so I really don't want to install another one, though I hear the whole OpenGL deal is much smoother on VS. I'm hoping it's something I'm doing wrong as opposed to the source code needing fixing like it did earlier when I tried to build the SDK...

Sponsor:

#2 abcdef44   Banned   -  Reputation: 2

Like
0Likes
Like

Posted 24 August 2012 - 05:27 AM

I'm fine with Eclipse... Without having ever used glut, I guess you probably need to link to -lglut and not freeglut?

#3 BitMaster   Crossbones+   -  Reputation: 4075

Like
0Likes
Like

Posted 24 August 2012 - 07:17 AM

In general the use of glut is discouraged because it is unmaintained and old. freeglut is a reasonable alternative and should provide all the needed symbols. I'm not familiar enough with Eclipse and C++ to debug the issue, but it should work on principle.

Did you compile freeglut yourself or did you try the precompiled version?

#4 s33d   Members   -  Reputation: 120

Like
0Likes
Like

Posted 25 August 2012 - 09:37 AM

In general the use of glut is discouraged because it is unmaintained and old. freeglut is a reasonable alternative and should provide all the needed symbols. I'm not familiar enough with Eclipse and C++ to debug the issue, but it should work on principle.

Did you compile freeglut yourself or did you try the precompiled version?


Compiled it myself. I have a few tutorials that use it, so I know it works. They have all the libraries in a subfolder though...

#5 BitMaster   Crossbones+   -  Reputation: 4075

Like
0Likes
Like

Posted 27 August 2012 - 02:29 AM

Do you get a different error if you rename/remove the freeglut library file? Also, is there any other output by the linker? Can you make the linker more verbose (i.e. to say exactly which libraries it is opening and which functions it is taking out of there)? I know MSVC has the /VERBOSE family of switches but I'm not sure about MinGW.

#6 Murdocki   Members   -  Reputation: 274

Like
0Likes
Like

Posted 27 August 2012 - 05:08 AM

i had issues with linking static libraries in eclipse as well. For me the issue was that the libraries i tried to link were not in a subfolder of the project's root (even output libraries from other projects also in the workspace could not be linked).

To fix this i just made a libs folder, pasted all the libraries in there and then linked them.

You may also have to take a look at the order in which you're linking the libraries. Not sure why but this was an issue for me as well, it may have something to do with something else though so try the other thing first.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS