使用MinGW64 gcc建造GLFW——入口符号警告和;链接器错误

使用MinGW64 gcc建造GLFW——入口符号警告和;链接器错误,gcc,64-bit,mingw,msys,glfw,Gcc,64 Bit,Mingw,Msys,Glfw,这是一个全新的Win7 64位安装,使用最新的MinGW64,在一个干净的(新提取的)GLFW 2.7.5源目录中,调用它们的make win32 msys命令 [A]构建LIB #1——gcc-c-I-I处的警告-Wall-mwin32-O2-o win32_init.o win32_init.c: win32_init.c: In function '_glfwPlatformTerminate': win32_init.c:353:27: warning: cast to pointer

这是一个全新的Win7 64位安装,使用最新的MinGW64,在一个干净的(新提取的)GLFW 2.7.5源目录中,调用它们的make win32 msys命令

[A]构建LIB

#1——gcc-c-I-I处的警告-Wall-mwin32-O2-o win32_init.o win32_init.c:

win32_init.c: In function '_glfwPlatformTerminate':
win32_init.c:353:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
win32_init.c: In function '_glfwPlatformTerminate':
win32_init.c:353:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
#2——gcc-c-I-I处的警告-Wall-mwin32-O2-mdll-DGLFW_BUILD_DLL-D_GLFW_NO_DLOAD_GDI32-D_GLFW_NO_DLOAD_WINMM-o win32_init_DLL.o win32_init.c:

win32_init.c: In function '_glfwPlatformTerminate':
win32_init.c:353:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
win32_init.c: In function '_glfwPlatformTerminate':
win32_init.c:353:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
但是相关的输出文件确实是在。\lib\win32中创建的:glfw.dll、libglfwdll.a和libglfw.a。但是我担心这些可能会被破坏,因为我以后不可能通过gcc链接到它们——这与本文中进一步描述的最后一个问题相同

[B]构建示例

#3--triangle.exe、pong3d.exe、splitview.exe、mipmaps.exe、gears.exe、boing.exe、wave.exe、heightmap.exe处的警告:

c:/mingw64/x86_64-w64-mingw32/bin/ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaulting to 0000000000401000
但是,listmodes.exe、mthello.exe、mtbench.exe和particles.exe的情况并非如此,它们的构建很好。事实上,这4个是此后唯一正确运行的,其他4个只是立即退出,没有输出或错误(当然,因为它们没有有效的入口点)

[C]构建测试

  • 在accurity.exe和dynamic.exe处发出警告:

    c:/mingw64/x86_64-w64-mingw32/bin/ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaulting to 0000000000401000
    
  • defaults.exe没有这样的问题。对于dynamic.exe,将继续执行以下错误:

    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x1c): undefined reference to `__imp_glfwGetVersion'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x62): undefined reference to `__imp_glfwInit'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0xcf): undefined reference to `__imp_glfwOpenWindow'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x10b): undefined reference to `__imp_glfwSetWindowTitle'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x118): undefined reference to `__imp_glfwSetWindowSizeCallback'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x123): undefined reference to `__imp_glfwSwapInterval'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x14a): undefined reference to `__imp_glfwGetWindowParam'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x151): undefined reference to `__imp_glfwSwapBuffers'
    C:\Users\roxor\AppData\Local\Temp\cc8hsorn.o:dynamic.c:(.text.startup+0x174): undefined reference to `__imp_glfwTerminate'
    collect2: ld returned 1 exit status
    make[1]: *** [dynamic.exe] Error 1
    make[1]: Leaving directory `/c/glfw64/tests'
    make: *** [win32-msys] Error 2
    
    现在,后一个是加载DLL的测试程序。您可能认为这只是在正确的位置缺少必要的lib(.a和.dll),但请注意,在这一点上,我确实在正确的位置有所有必要的include和lib(来自与上面完全相同的早期GLFW版本,相同的版本,相同的警告,相同的输出文件):

    • \MinGW64\x86_64-w64-mingw32\lib中的libglfwdll.a(libglu32.a、libopengl32.a旁边)
    • glfw.h在\MinGW64\x86_64-w64-mingw32\include\GL中(紧挨GL.h、glaux.h、glu.h)
    • \windows和\windows\system32中的glfw.dll(紧挨着opengl32.dll,glu32.dll)
      • 我也犯了同样的错误。 通过更改文件
        glfw-2.7.5\tests\Makefile.win32.mingw
        :12从

        SOLIB     = ../lib/win32/libglfwdll.a
        


        我遇到了完全相同的问题,在研究错误和警告时,我找到了“找不到输入符号错误”警告的修复方法:

        在示例/Makefile.win32.msys和测试/Makefile.win32.msys中,更改行

        WINDOWS=-mwindows-e\u mainCRTStartup

        WINDOWS=-mwindows

        Kabie的修复有助于解决动态链接错误


        我不能100%确定这是一个正确的解决方案,因为我首先不完全理解替换入口点名称的原因,但至少测试似乎有效,示例也在运行。

        问题a是无害的,但我添加了一个额外的强制转换来删除警告。问题BC是由于GLFW中的两个错误造成的。它们现在已经被修复,部分是由于这个线程。感谢您将其发布到GLFW bug跟踪器,并因此引起我的注意。修复程序将包含在2.7.6版本中。在那之前,你可以从车上抓起行李箱

        问题C很难解决,因此有人可能会觉得总结很有用

        32位的正确链接需要一个带有装饰符号的.def文件,但该文件不能用于64位。解决方案是让GCC为给定的体系结构生成正确的.def文件

        这是通过链接DLL两次来完成的。首先将其链接为导出装饰符号(默认设置)并生成.def文件(使用
        -Wl,--output def,file.def
        ),然后再次链接而不进行装饰(使用
        -kill at
        )以生成最终的DLL。生成的.def文件可以像往常一样与
        dlltool
        一起使用,以生成导入库


        在研究过程中,我发现最有用的资源是,它概括了这种方法。

        哇,我得试试。我会在这里报道。现在GLFW、Go和Mingw-w64的最新版本都非常好用!感谢您添加64位支持:)