本文介绍了freeglut 错误 LNK1104的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我想使用来自非官方 opengl sdk 的 freeglut 库.

In my project I want to use a freeglut library from the unofficial opengl sdk.

我使用 Premake 为 vs2010 生成构建文件.然后我构建了所有库(调试).在我的项目中,我为 freeglut 设置了 Additional Include Directories、Additional Library Directories.在其他依赖项中,我添加了 freeglutD.lib.

I used Premake to generate build files for vs2010. Then I built all libraries (debug). In my project I set Additional Include Directories, Additional Library Directories for the freeglut. In additional dependencies I added freeglutD.lib.

在代码中,我只包含了一个 freeglut 标头.当我想运行程序时出现错误:

In the code I just include a freeglut header. When I want to run the program I get an error:

>LINK : fatal error LNK1104: cannot open file 'freeglut.lib'.

freeglutD.lib 是 sdk/freeglut/lib 中唯一的文件.sdk中没有freeglut.dllfreeglut.lib.

The freeglutD.lib is the only file in sdk/freeglut/lib. There is no freeglut.dll and freeglut.lib in sdk.

之前我使用 link 中的 freeglut 2.8.0 MSVC 包,其中动态链接(包含freeglut.dll),一切正常.

Earlier I was using freeglut 2.8.0 MSVC Package from link which is linked dynamically (contain freeglut.dll) and everything works fine.

怎么了?

推荐答案

我猜你在使用 SDK 的文档中忘记了这些行:

My guess is that you forgot these lines from the documentation on using the SDK:

您还需要在命令行中添加一些#defines.它们是:

  • FREEGLUT_STATIC
  • _LIB
  • FREEGLUT_LIB_PRAGMAS=0

您需要 FREEGLUT_STATIC 让 GLUT 知道它是静态链接的.否则它会寻找一个 DLL.

You need that FREEGLUT_STATIC to let GLUT know that it's linking statically. Otherwise it looks for a DLL.

这篇关于freeglut 错误 LNK1104的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 22:01