Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple definition of `DllMainCRTStartup@12' while building glew on windows with mingw32

I followed this topic: Building glew on windows with mingw but something went wrong here:

gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

I get this error:

C:\MinGW\dev_lib\glew-2.0.0>gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 src/glew.o:glew.c:(.text+0x28f80): multiple definition of `DllMainCRTStartup@12' c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../dllcrt2.o:(.text+0x60): first defined here collect2.exe: error: ld returned 1 exit status

Thanks for help.

like image 984
spin_orbit Avatar asked Jul 30 '16 11:07

spin_orbit


1 Answers

You need to link with the -nostdlib option like so:

gcc -nostdlib -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a    -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

Glew defines DllMainCRTStartup which is also defined in the CRT. Hence your problem.

like image 50
John Connors Avatar answered Sep 30 '22 13:09

John Connors