GCC SDL + GLEW 链接错误
我有一个静态库,在其中通过 GLEW 调用 OpenGL 扩展函数。由于该项目是在 GCC (NetBeans 7.0) 中构建的,并且 GLEW 的二进制文件仅以 Visual-C 风格提供,因此我使用 GCC 将 GLEW (1.7.0) 构建为静态库。 (我也很感兴趣为什么这是必要的,因为 GLEW 似乎是纯 C,其中 ABI 和交叉编译器兼容性不是问题。)
在我的静态库中,我将 GLEW_STATIC 和 NO_SDL_GLEXT 定义为项目预处理器指令(- D),然后我
#include "GL/glew.h"
#include "SDL/SDL.h"
将静态库链接到(测试)应用程序中,该应用程序还按以下顺序链接到以下库:
my_static_library
mingw32
glew32
opengl32
SDLmain
SDL
此设置在我的静态库中给出了两个未定义的引用错误库:
undefined reference to `_imp____glewGetStringi'
undefined reference to `_imp__glewInit'
事实上,这是对静态库中的 GLEW 功能进行的两次调用。然而,链接器曾经抱怨过其他调用(在 -DGLEW_STATIC 之前),但现在似乎没问题。
我无法通过交换 opengl32 和 glew32 的链接顺序来改善这种情况(还有一些对 wgl...
调用的未定义引用)。此外,GLEW_STATIC(和 NO_SDL_GLEXT)曾经在测试应用程序中定义,但已被删除并且似乎并不重要。
为什么会出现其余错误以及我可以采取什么措施来消除它们,即如何在带有 SDL 的 GCC 中使用 GLEW?
I have a static library in which I'm calling OpenGL extension functions via GLEW. As the project is being built in GCC (NetBeans 7.0), and GLEW's binaries are only shipped in Visual-C flavor, I have built GLEW (1.7.0) as a static library, with GCC. (I would also be interested why this is necessary, as GLEW seems to be pure C, in which ABI and cross-compiler compatibility isn't an issue AFAIK.)
In my static library I define GLEW_STATIC and NO_SDL_GLEXT as project preprocessor directives (-D), then I
#include "GL/glew.h"
#include "SDL/SDL.h"
The static library is then linked against in a (test) application, which also links against the following libraries, in the following order:
my_static_library
mingw32
glew32
opengl32
SDLmain
SDL
This setup gives me two undefined reference errors in my static library:
undefined reference to `_imp____glewGetStringi'
undefined reference to `_imp__glewInit'
Indeed, these are two calls made to GLEW functionality, in the static library. There are however other calls that the linker used to complain about (before -DGLEW_STATIC), yet seem to be ok now.
I wasn't able to improve the situation by swapping the order of linkage to opengl32 and glew32 (some more undef'd refs to wgl...
calls). Furthermore, GLEW_STATIC (and NO_SDL_GLEXT) used to be defined in the test application but that has been removed and doesn't seem to matter.
Why do the remaining errors occur and what can I do to get rid of them, i.e. how can I use GLEW in GCC with SDL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的库是以这样的方式构建的,以便链接到 GLEW 的 DLL 版本 -
_imp____glewGetStringi
和_imp__glewInit
是导入库符号,即定义的组合导致以下结果编译时出现一行;如果您在编译库时没有定义
GLEW_STATIC
(但您这样做了;仔细检查每个对象)或者
您的 GLEW 版本的标头中存在错误,则可能会发生这种情况。在 GLEW 1.7.0 中,它按预期工作。
You library was built in such a way, as to link to the DLL version of GLEW -
_imp____glewGetStringi
and_imp__glewInit
are import library symbols, i.e. the combination of defines resulted in the following line appearing when compiling;This can happen if you don't define
GLEW_STATIC
while compiling your library (but you do; double check each object)or
your version of GLEW has a bug in the headers. In GLEW 1.7.0 it works as expected.