无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号

无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号

参考官方配置指南:http://glew.sourceforge.net/install.html

  1. 编译build开源库中,引入了gluw, 正常引入:.h, .lib .dll 文件后,出现下列错误
<span style="font-size:14px;">>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___glewMultiTexCoord1fARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___glewMultiTexCoord2fARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___wglewGetPbufferDCARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___wglewCreatePbufferARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___wglewChoosePixelFormatARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___wglewBindTexImageARB
>gpu_util.obj : error LNK2001: 无法解析的外部符号 ___glewActiveTextureARB
>main.obj : error LNK2001: 无法解析的外部符号 ___glewActiveTextureARB
>main.obj : error LNK2019: 无法解析的外部符号 _glewGetString@,该符号在函数 _init 中被引用
>main.obj : error LNK2019: 无法解析的外部符号 _glewInit@,该符号在函数 _init 中被引用
>Release\gpu_sph.exe : fatal error LNK1120:  个无法解析的外部命令</span>  

我检查了自己的lib文件的链接还有附加库的目录都没有问题,后来在一个国外网站找到了解决的办法:

You have now set up the project to include the appropriate headers and build against the correct libraries. These particular instructions will treat GLEW and GLUT as “dynamically linked” libraries. This means that you will have to distribute the glut32.dll and glew32.dll files along with your program for users without GLUT and GLEW installed.

GLEW, 采用静态连接, 这样可以避免,将glew32.dll , glut32.dll动态库同程序一起发布。

GLEW gives you the option of “static linking,” which allows you to avoid redistributing glew32.dll. To do this, #define GLEW_STATIC before the #include <GL/glew.h> line. Also choose to link against glew32s.lib instead of glew32.lib.

按照他的说法,我尝试了把glew32.lib改为glew32s.lib(前提,你要把glew32s.lib已经拷贝到了lib文件夹下面),还有要把链接器->常规里面的附加库的目录设为glew32s.lib所在的文件夹。
点击调试,ok!!!
另一个方法:就是把glew32.lib改为glew32s.lib,把链接器->常规里面的附加库的目录设为glew.lib所在的文件夹,在#include <GL/glew.h>前面加上#define GLEW_STATIC

无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值