我在windows下使用代码块,当我运行构建的exe文件时出现问题。通过代码块运行没有错误。 A单独不起作用。我只使用sdl + opengl,但问题显然不在于它们。 最初,需要libstdc,已添加链接到链接器选项
-static-libgcc -static-libstdc++
然后是另一个pthread,依此类推。在Internet上,我发现添加到链接器选项的方法是
-static -lpthread -lole32 -limm32 -lgdi32 -lwinmm -loleaut32
接下来,编译器开始发布
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:566: undefined reference to `GetFileVersionInfoSizeA@8'
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:570: undefined reference to `GetFileVersionInfoA@16'
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:571: undefined reference to `VerQueryValueA@16'
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:566: undefined reference to `GetFileVersionInfoSizeA@8'
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:570: undefined reference to `GetFileVersionInfoA@16'
/Users/slouken/release/SDL/SDL2-2.0.4-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:571: undefined reference to `VerQueryValueA@16'
collect2.exe: error: ld returned 1 exit status
我找到了这些功能,他们需要winver.h。包括在内,但错误仍然存在。 我以为我可以修复它连接mincore lib(实现Winver.h就在这里),但它没有看到mingw
ld.exe||cannot find -lmincore|
||error: ld returned 1 exit status|
我已经包含在项目中的所有内容
#include<iostream>
#include<cstring>
#include<windows.h>
#include<objbase.h>
#include<winver.h>
#include<oleauto.h>
#include"SDL.h"
#include"SDL_main.h"
#include"SDL_opengl.h"
#include"SDL_image.h"
#include"GL/gl.h"
#include"GL/glu.h"