c - 使用 mingw32 在 Windows 上构建 glew 时 `DllMainCRTStartup@12' 的多个定义

标签 c windows gcc mingw glew

我关注了这个主题:Building glew on windows with mingw但这里出了点问题:

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

我收到这个错误:

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): `DllMainCRTStartup@12' 的多重定义 c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../dllcrt2.o:(.text+0x60): 首先在这里定义 collect2.exe:错误:ld 返回了 1 个退出状态

感谢您的帮助。

最佳答案

您需要像这样使用 -nostdlib 选项进行链接:

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 定义了 CRT 中也定义的 DllMainCRTStartup。因此你的问题。

关于c - 使用 mingw32 在 Windows 上构建 glew 时 `DllMainCRTStartup@12' 的多个定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38673228/

相关文章:

创建第二个数组时,C 数组给出地址而不是值

c++ - LookupAddressForName 做什么,为什么这么慢

c - 库中的链接器脚本变量阻止动态链接

debugging - 如何让gdb一起打印两个源代码对应的反汇编代码?

c - C 字数统计程序

在C中递归计算PI

c - 操作数组

windows - 为什么程序不直接终止并重新启动 explorer.exe?

windows - 颜色问题

gcc - 使用gnueabihf为ARMv6构建