I’m new to OpenGL. I tried compiling the first program in the red book (the white square against a black background) and was successful. Now I’m trying to build the classic Asteroids game. My compilation command is as follows:
But this spits out the following error. I have no idea what it is:
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/…/…/…/x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference to main’
collect2: ld returned 1 exit status
The simple answer to this not so obscure error is that there isn’t a main function anywhere in the source code - thus there is no entry point for the application and therefore linkage fails.
BTW, this is nothing specific to Linux, Windows, Unix, OSX or OpenGL. It’s C/C++ beginners mistake.
Actually compiling the .cpp files individually gives me the same error. And yes, I DO have a main() function. What I found out fixed the issue is in the appendix of the blue book:
now I don’t know what the libraries X11, Xi, and m do but it works with them. There’s another library the book says to link to. It’s called Xmu but my system can’t find it and it works without it.
X11 is a protocol libX11 is the interface library for your implementation of the X Window System. libXi is the X Input Library libm is the C math library. I doubt that linking against these libs solved your problem.