c++ - 试图让我的游戏在 VC 2010 中运行,似乎无法链接 SOIL 库,不知道如何链接,包括游戏源代码

标签 c++ linker

我使用 CodeBlocks 已经有一段时间了,因为我用 C++ 制作了一个业余爱好游戏。遇到一个障碍,我想随时查看数组中所有数据的当前值,CodeBlocks 似乎没有这种能力。同事(专业游戏程序员)告诉我应该使用 Visual Studio。

过去曾使用过 Visual Studio C#,在调试我制作的其他小游戏时使用断点非常方便,然后通过大列表查看特定数组值或任何其他值当时我的计划中的值(value)。

所以我在 VC2010 中新建了一个空白项目,并将我所有的代码文件添加到该项目中。我知道我必须链接图书馆等,我花了最后几个小时试图弄清楚如何做到这一点。但即使完成所有这些,我仍然会收到链接错误(我认为)

第一个问题是:

fatal error C1083: Cannot open include file: 'gl\glext.h': No such file or directory

所以我将其注释掉,看看我能走多远。

最终不得不添加到我的 main.cpp 文件中

#pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "glu32.lib")
#pragma comment (lib, "libsoil.lib")

我最终将 libsoil.a 文件复制到 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib 并将其重命名为 libsoil.lib(如在作者的网站上说明 http://www.lonesock.net/soil.html )

所以现在我在编译时得到了这个

1>libsoil.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol ___chkstk referenced in function _stbi_zlib_decode_noheader_buffer
1>libsoil.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2
1>C:\Repositories\HappyHelperPuppy\CppVer\HappyHelperPuppy\Debug\HappyHelperPuppy.exe : fatal error LNK1120: 2 unresolved externals

..我不知道下一步该做什么。我在 Google 和论坛上花了很长时间,但我真的不知道该怎么做。

因此,作为最后的努力,我正在压缩我所有的代码和项目文件,让任何有兴趣的人看看他们是否能找到解决方案。这个游戏不会有任何我想保密的 secret 功能,所有的艺术都来自很久以前的公开游戏比赛(“TIGSource Assembly”对于那些知道它是什么的人)或来自 DeviantArt(只是想要一些东西在我做的时候看看,不会是最终的游戏发行艺术)

代码/游戏可以在这里找到http://users.on.net/~infernoraven/hhp_busted_code.zip (27mb)

SOIL 库应该在它自己的 soil.zip 的主目录中

任何帮助都会很好,但我真的很沮丧,因为我似乎大部分时间都花在与 IDE/编译器打交道或一些烦人的语法问题上。

CodeBlocks 项目文件也应该在那里,所以如果你..

  • 取消注释掉 glext.h
  • 链接到土壤
  • 链接到 libopengl32 和 libglu32

希望它能为您编译。否则应该有一个由 CodeBlocks 预编译的 HappyHelperPuppy.exe,它应该有望运行并让您了解假设会发生什么


在 SOIL 包中有许多用于 visual studio 的项目文件。当我尝试加载 VC9 并将其转换为 VC10 时,出现转换错误。

Conversion Report - SOIL.vcproj: 
Converting project file 'C:\Documents and Settings\Administrator\My Documents\Downloads\soil\Simple OpenGL Image Library\projects\VC9\SOIL.vcproj'. 
Failed to upgrade platform 'x64'. Please make sure you have it installed under '%vctargetspath%\platforms\x64' 
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings. 
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion. 
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion. 
Failed to upgrade 'Debug|x64'. Please make sure you have the corresponding platform installed under '%vctargetspath%\platforms\x64' 
The project configuration dimension name/value "(Platform, Win32)" was not found in the project manifest. 
Project upgrade failed. 

如果我使用 VC8 项目文件并尝试升级它,VC2010 生成的 libSOIL.lib 文件会抛出一条错误消息“无法启动程序...\SOIL.lib 指定的文件是无法识别或不受支持的二进制文件格式”

但是作者在他的网站上说我可以简单地将 libSOIL.a 文件重命名为 libSOIL.lib 文件,它应该可以工作。

最佳答案

soil.zip 文件包含文件夹项目下的一些 .sln 文件。使用正确的 .sln 文件构建库,然后将您的项目链接到该库。它在我这边运行良好。

关于c++ - 试图让我的游戏在 VC 2010 中运行,似乎无法链接 SOIL 库,不知道如何链接,包括游戏源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6706330/

相关文章:

c++ - "undefined reference to"在 Ubuntu 上链接

C++ Visual Studio 2012 -> 2010

c++ - 如果 gdb frams/bt 显示 "??"但没有 readalbe 函数名称,会发生什么情况?

c++ - C++ 中的 volatile unsigned *

c++ - 使用 INF 文件 c++ 以编程方式安装驱动程序

c++ - 我的程序编写每十亿个组合的更有效方法?

visual-studio-2010 - 在带有openCV的Visual Studios 2010中构建项目时无法解析的外部符号

c - gcc 静态库链接与动态链接

macos - 如何在Mac OSX下使用gcc设置可执行文件的运行时路径(-rpath)?

c - 如何使用静态链接到其中的所有库创建 .so 文件?