首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Glew链接问题

Glew链接问题
EN

Stack Overflow用户
提问于 2015-09-12 09:41:45
回答 1查看 1.4K关注 0票数 0

当我尝试动态链接到glew时,链接器会抛出像undefined reference: __imp___glewGenVertexArrays这样的错误。基本含义很清楚--链接器找不到任何地址来链接函数调用对象。

让我烦恼的是,我使用了普通的glw.h头文件,并将其链接到glew32 (而不是glew32s --稍后我将讨论这个问题)。在不定义#define GLEW_STATIC的情况下,Glew应该根据实际情况动态链接。但是,未定义的错误表明,它正试图以静态方式针对它们进行链接。因此,我通过链接到glew32s并在#include "GL/glew.h"之前添加了#define GLEW_STATIC来修正它。

但在我看来,这只是一个工作-我想知道为什么glew假设静态链接,当没有要求。尤其是当您只通过不定义glew32s来链接到GLEW_STATIC时,它甚至不能工作。

更新我正在使用gcc 5.1.0 mingw64

当链接到没有定义glew32GLEW_STATIC时,完全错误:

代码语言:javascript
复制
src\SDLWrapper\CoreWindowSDL.o: In function `CoreWindow_SDL::enterMain()':
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:61: undefined reference to `__imp___GLEW_VERSION_4_5'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:68: undefined reference to `__imp___glewGenVertexArrays'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:69: undefined reference to `__imp___glewBindVertexArray'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:74: undefined reference to `__imp___glewGenBuffers'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:76: undefined reference to `__imp___glewBindBuffer'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:77: undefined reference to `__imp___glewBufferData'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:109: undefined reference to `__imp___glewEnableVertexAttribArray'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:110: undefined reference to `__imp___glewBindBuffer'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:111: undefined reference to `__imp___glewVertexAttribPointer'
D:\workspace\Engine\Debug/../src/SDLWrapper/CoreWindowSDL.cpp:114: undefined reference to `__imp___glewDisableVertexAttribArray'
collect2.exe: error: ld returned 1 exit status

问题是,这些函数应该在运行时加载,为什么gcc/glew试图针对它们进行链接?

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2015-09-12 09:59:25

我尝试使用VS2015和GleW1.13.0为x86和x64重现您的问题,一切都很好。没有链接错误。

Glew应该在盒子外动态链接。但是,未定义的错误表明,它正试图以静态方式针对它们进行链接。

你理解错了。它静态地链接到dll导入库,但当您的程序执行时,它将动态链接glew.dll。链接到glw32.lib文件,即dll导入库,将在链接时解析对符号的引用。启动编译后的程序时,dll将被动态链接。

链接静态库后,不需要dll。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32537359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档