"extern" problem

On Ubuntu, I am trying to compile a GL project consisting of 3 source files. One of them which has the main function in it has this code section

1
2
3
4
extern void gfxInit();
extern GLfloat CylVertexArray[];
extern GLubyte CylFaceArray[];
extern int CylNofFaceVertex[];


When compiling with this command
"gcc cyl.cpp -lglut -lGLU -lGL -o cyl"

I get these errors:


/tmp/ccTmVLQZ.o: In function `main':
cyl.cpp:(.text+0x7d): undefined reference to `gfxInit()'
/tmp/ccTmVLQZ.o: In function `displayFunc()':
cyl.cpp:(.text+0xb6): undefined reference to `CylVertexArray'
cyl.cpp:(.text+0xf2): undefined reference to `CylFaceArray'
cyl.cpp:(.text+0xfc): undefined reference to `CylNofFaceVertex'
cyl.cpp:(.text+0x122): undefined reference to `CylNofFaceVertex'
collect2: ld returned 1 exit status


I really do not know what -lglut,-lGL and that stuff mean, but I thought that i got these errors because of the wrong usage of extern function.
Any suggestions?

Thanks in advance
The things you refer to are the OpenGL libraries.

Your problem is that if you have 3 source (.cpp) files, you need to compile and link all of them,
not just cyl.cpp.

So

g++ file1.cpp file2.cpp file3.cpp -lglut -lGLU -lGL -o cyl
I knew it was a linking issue. I just didn't find how to link these files. Thanks a lot. It is solved now.
Topic archived. No new replies allowed.