2012-04-30 41 views
3

这是一个相当新鲜的香草Win7 64位安装与最新的MinGW64,在干净的(新鲜提取的)GLFW 2.7.5源目录中调用它们的使win32-msys命令。构建GLFW与MinGW64 gcc - 入门符号警告和链接器错误

[A]大厦库

#1 - 在GCC -c -I警告。 -I .. -Wall -mwin32 -02 -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] 

#2 - 在GCC -c -I警告。 -I .. -Wall -mwin32 -02 -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] 

但相关的输出文件获得创建\ 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只是后来唯一正常运行的,其他只是在没有输出或错误的情况下立即退出(自然,因为它们没有有效的入口点)。

[C]构建测试

  1. 警告在accuracy.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的测试程序。您可能会认为这只是在正确的位置丢失了必要的库(.a和.dll),但请注意,在这一点上,我有所有必需的包含和库(从早期的GLFW make,即正好是完全相同如上述,相同的版本,同样的警告,相同的输出文件)在正确的地方:

  • libglfwdll.a在\ MinGW64 \ x86_64的-W64-的mingw32 \ LIB(旁边libglu32.a,libopengl32.a)
  • glfw.h在\ MinGW64 \ x86_64的-W64-的mingw32 \包括\ GL(旁gl.h,glaux.h,glu.h)
  • glfw.dll在\ Windows和\ Windows \ System32下(下到opengl32.dll,glu32.dll)

回答

3

问题A是无害的,但我添加了一个额外的演员来删除警告。问题BC归因于GLFW中的两个错误。现在他们已经修好了,部分归功于这个主题。感谢您将它发布到GLFW错误跟踪器,并将其引入我的注意。修补程序将包含在2.7.6版本中。在此之前,您可以从GLFW Subversion repository中获取行李箱。

问题C很难解决,有人可能会发现一个总结有用。

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

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

我在研究这个过程中找到的最有用的资源是Stdcall and DLL tools of MSVC and MinGW,其中还有其他概述了这种方法。

+0

现在,它与GLFW,Go和Mingw-w64的最新发行版本一起工作良好!感谢您添加64位支持:) – metaleap

3

我也得到了同样的错误。 通过改变解决了文件glfw-2.7.5\tests\Makefile.win32.mingw:12

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

SOLIB  = ../lib/win32/glfw.dll 
+0

哇,要试试。那么会在这里回报。 – metaleap

2

我遇到了完全一样的问题,而研究中的错误和警告我找到了解决的“找不到入口符号错误”警告:

在实施例/ Makefile.win32.msys和测试/ Makefile.win32.msys改变线

WINDOWS = -mwindows -e _mainCRTStartup

WINDOWS = -mwindows

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

我不是100%肯定这是一个正确的解决方案,因为我不完全理解的原因首先替代入口点名称,但至少测试似乎可以正常工作并运行示例。