无法链接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

最新文章

  1. [LeetCode] Lowest Common Ancestor of a Binary Tree 二叉树的最小共同父节点
  2. Swift_1基础
  3. centos 7.0 PHP 5.6.5 安装过程 (php+nginx)
  4. hiho #1361 Playfair密码表
  5. progressBar走马灯设置
  6. Sql语句,先查询再插入一条语句完成。
  7. java观察者模式的实现
  8. IOS6学习笔记(三)
  9. github pages 添加godaddy的dns解析
  10. JavaScript constructor 属性
  11. 5.中文问题(自身,操作系统级别,应用软件的本身),mysql数据库备份
  12. Java学习之道:空指针错误求解救????????????
  13. js中的拷贝问题
  14. vue全局组件-父子组件传值
  15. while 循环,存储过程
  16. Spring的jdbc模板2:使用开源的连接池
  17. 【vue】钩子函数生命周期
  18. 阶段01Java基础day17集合框架03
  19. web服务器tomcat入门实战
  20. js变量按照存储方式区分,有哪些类型,并表述其特点

热门文章

  1. 5A - 超级楼梯
  2. url中含有%
  3. PAT 1071 小赌怡情(15)(代码)
  4. swoole的EventLoop学习
  5. hdu 1686 &amp; poj 2406 &amp; poj 2752 (KMP入门三弹连发)
  6. Oracle数据库mybatis 插入空值时报错(with JdbcType OTHER)
  7. Java中的权限修饰符
  8. 为什么要用jvm .
  9. JS下拉页面时一个横幅的样式和js
  10. Maven中maven-source-plugin,maven-javadoc-plugin插件的使用