PDA

Click to See Complete Forum and Search --> : Uresolved exernals:(


Drakon
Dec 23rd, 2001, 01:31 PM
I have a main.cpp and a main.h. I have most of my ints/doubles in the main.h, and when I compile my main.cpp, it compiles fine. But when I try to run my program, I get this:

--------------------Configuration: Maze - Win32 Debug--------------------
Linking...
Main.obj : error LNK2001: unresolved external symbol "double angle" (?angle@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double vectorz" (?vectorz@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double vectorx" (?vectorx@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double posx" (?posx@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double posz" (?posz@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double viewx" (?viewx@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double viewz" (?viewz@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double upx" (?upx@@3NA)
Main.obj : error LNK2001: unresolved external symbol "double upz" (?upz@@3NA)
Debug/Maze.exe : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.

Anyone know whats wrong?

parksie
Dec 23rd, 2001, 01:42 PM
Are they global to the program, i.e. are they straight inside the .h file (not within a class or anything)?

PS: You haven't even built the program yet since you can't run without linking.

PPS: Try doing "Rebuild All" - that occasionally fixes symbol problems.

Drakon
Dec 23rd, 2001, 01:58 PM
Heres my .h file:

#ifndef _MAIN_H
#define _MAIN_H

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include <math.h>

extern double posx;
extern double posy;
extern double posz;

extern double viewx;
extern double viewy;
extern double viewz;

extern double upx;
extern double upy;
extern double upz;

extern double vectorx;
extern double vectory;
extern double vectorz;

extern double angle;

#endif

Does it help if they are in a class?

parksie
Dec 23rd, 2001, 02:16 PM
Ah. Are they defined as non-externs in your .cpp file?

What that does, is to define the symbols - however if they're not defined in an object file (i.e. the result of compiling a single .cpp file) then the linker can't find them.

Drakon
Dec 23rd, 2001, 02:53 PM
It works now:) Thanks!