PDA

View Full Version : Unresolved external errors



hi_speed_idiot
03-06-2002, 03:09 PM
The following is a basic polygon program written in C++ with Cbuilder5, and every time i compile or run it, i get the linker errors:

[Linker error] - Unresolved external '_Form1' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\PROJECT1.OBJ
[Linker error] - Unresolved external 'TForm1::' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\PROJECT1.OBJ

If i run the DOS command line module(bcc32) i get these errors instead:

Unresolved external 'glutInit' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutInitDisplayMode' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutInitWindowSize' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutInitWindowPosition' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutCreateWindow' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutDisplayFunc' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ
Unresolved external 'glutMainLoop' referenced from C:\BORLAND\CBUILDER5\MYSOURCE\GLUT2.OBJ

********** ********** **********

FOLLOWING is the source code of the program:

#include <windows.h>
#include <gl/glut.h>
#include <stdlib.h>

void init(void);
void display(void);


int main(int argc, char** argv) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return(0);
}

void init(void) {

glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

void display(void) {

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
}

********** ********** **********

I have already made sure i had all the necessary header, library and DLL files stored in the correct places(though perhaps i do not have a compatible set of them given that some have different creation dates[all 32bit format still]).

If you can tell me where to get a complete and updated set of the OpenGL(the 3 LIB, H & DLL) files, or if you can help me overcome this problem, as i am unsure if it is a C++ error or a Borland error, i would greatly appreciate it as i seem to be stumped with it, Thank you.

zeckensack
03-06-2002, 03:37 PM
Errr, you did explicitly tell your linker to link with glut32.lib, now did you? http://www.opengl.org/discussion_boards/ubb/smile.gif

hi_speed_idiot
03-07-2002, 01:56 AM
NO, so how do i do that? I can't see where to do that...

The_V|k|ng
03-07-2002, 05:14 AM
You can add

#pragma comment(lib, "glut32.lib")

just behind your includes. Just make sure you have the glut32.lib in the same directory as your .cpp-file.

The_V|k|ng
03-07-2002, 05:28 AM
And, sorry I forgot, for you are using Borland (as I do, too), you should use implib to import the downloaded libs into Borland style. I think the syntax is simply

implib glut32.lib

but I am not too sure. You'll find out... http://www.opengl.org/discussion_boards/ubb/wink.gif
Another way of compiling with the linked .lib is calling

bcc32 Program.cpp glut32.lib

I myself couldnt make a properly working OpenGL-program without GLUT and the DOS-compiler (with is essential with GLUT, I believe), but so far it works just fine for me... http://www.opengl.org/discussion_boards/ubb/smile.gif For updated files, check the GLUT-page at this site: http://www.opengl.org/developers/documentation/glut.html. You'll find plenty of info there and elsewhere.
Good luck coding!

The_V|k|ng


P.S.: Thanx again, zeckensack, for your hint concerning glEnd().... http://www.opengl.org/discussion_boards/ubb/wink.gif

hi_speed_idiot
03-07-2002, 01:05 PM
That works marvellously, thanks Viking. Now i can actually see what it is i am doing, thanks again.