Problem: As using link option --kill-at, the symbols of functions in DLL file is without '@x' when using
__stdcall. But the objects linking to the library still ask for symbols with '@x'.
The solution is to reproduce the implib bridging the linking symbols with and without '@x'.
Function definition:
Build DLL and create DEF file.
The DEF file:
Delete unnecessary symbols.
Create new implib.
Symbols in object file.
编译 freeglut.dll 的脚本:
1 @echo off
2
3
4 gcc -fPIC -c ./freeglut-2.6.0/src/*.c -D__MINGW32__ -DFREEGLUT_EXPORTS /
-I./freeglut-2.6.0/include -I./freeglut -2.6.0/src -I./freeglut-2.6.0/include/GL
5
6 gcc -shared -o freeglut.dll *.o /
-Wl,--output-def,freeglut_origin.def,--out-implib,freeglut.dll.a,--kill-at -mwindows -lopengl32 -lglu32 -lwinmm
7
8 sed "s/glut.*/ =//g" freeglut_origin.def > freeglut.def
9
10 dlltool -d freeglut.def --dllname freeglut.dll --output-lib libfreeglut.dll.a --kill-at--
11
12 gcc -c freeglut-2.6.0/progs/demos/shapes/shapes.c -I./freeglut-2.6.0/include /
-I./freeglut-2.6.0/src -I./freegl ut-2.6.0/include/GL
13
14 gcc -o shapes.exe shapes.o -L. -lfreeglut -lopengl -mwindows
15
16 @pause