|
From: Schuster, J. (N-Compaq) <joe...@lm...> - 2003-10-08 20:37:06
|
Question on linking.
I'm trying to link a little test program against opengl32 just to test this out.
I'm doing all this under MSYS with MinGW.
###########################
#include <GL/gl.h>
void glEnable(GLenum);
int main()
{
glEnable(0);
}
##############################
# file name test.cpp
If I try to compile like this:
>>> g++ -o test test.cpp
I get this:
test.cpp: undefined reference to `glEnable@4'
Which is expected.
Now I add the library:
>>> g++ -lopengl32 -o test test.cpp
And I get this:
test.cpp: undefined reference to `glEnable@4'
So I figure that it can't find the library...
>>> g++ -L/mingw/lib -lopengl32 -o test test.cpp
But:
test.cpp: undefined reference to `glEnable@4'
Now... I add the library to the end as another object and it works:
>>> g++ -o test test.cpp /mingw/lib/libopengl32.a
This doesn't make any sence to me since the MinGW FAQ says that it should work correctly in the first way.
So what am I doing wrong?
ALSO. As I was playing around with this I went and got the OPENGL32.DLL from the system32 windows
directory and created and import library from that using:
>>> pexports.exe OPENGL32.DLL | sed "s/^_//" > opengl32.def
>>> dlltool -U -d opengl32.def -l libopengl32.a
Now this one doesn't work at all with my little test program because all the @* stuff is missing off of all
the functions. As per 'nm' of the *.a files.
So now I have two questions.
1. Where did the libopengl32.a file come from that is in the /mingw/lib directory if not from pexports/dlltool
2. Again, why can't I link normally using the -L and -l switches?
(BTW - I also have the same problem with the SDL library that I built under MinGW, so it's not just
for windows dlls and import libraries)
|