DevIL 库文件和依赖项

2023-12-19

好吧,事情就是这样。我有我需要的所有 IL 文件,即

DevIL.dll
DevIL.lib

ILU.dll
ILU.lib

ILUT.dll
ILUT.lib

config.h
config.h.in
devil_cpp_wrapper.h
devil_internal_exports.h
il.h
ilu.h
ilu_region.h
ilut.h
ilut_config.h

我的项目目录如下所示,假设我的项目名称是“Project1”

                 |-Debug---Project1.pdb
                 |
                 |            |---Debug---[loads of files]
                 |            |
                 |            |---Glut---[OpenGL files]
                 |            |
                 |            |---IL---[all the files mentioned above]
                 |-Project1---|
                 |            |---image.bmp
Project Folder---|            |
                 |            |---[header and .cpp files I made in the project]
                 |            |
                 |            |---[files produced by Visual Studio]
                 |          
                 |-ipch---[unrelated stuff]
                 |
                 |-Project1.sln
                 |
                 |-[other files VS created]

如前所述,我已将所有 DevIL 文件放入 IL 文件夹中,并且我确信我正在使用它们的 unicode 兼容版本,因为我在项目中使用 Unicode 字符集。在我的“附加依赖项”中我有

ilut.lib; ilu.lib; DevIL.lib;

所以,依赖关系就在那里,我知道这不是问题。

毕竟,我仍然收到链接器错误,主要是LNK2019:unresolved external symbol__imp_对于所有 IL 功能。

我缺少什么?在我看来,这可能与项目属性或文件本身有关......也许我错过了一个文件?

编辑:这是输出消息

1>------ Build started: Project: Final Year Project, Configuration: Debug Win32 ------
1>Build started 29/4/2011 12:46:04 pm.
1>InitializeBuildStatus:
1>  Touching "Debug\Final Year Project.unsuccessfulbuild".
1>ClCompile:
1>  Main.cpp
1>c:\users\xxxx\desktop\final year project 0.2\final year project\main.cpp(152): warning C4390: ';' : empty controlled statement found; is this the intent?
1>c:\users\xxxx\desktop\final year project 0.2\final year project\main.cpp(141): warning C4101: 'alpha' : unreferenced local variable
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilInit@0 referenced in function "public: static void __cdecl Main::Init(int,char * *)" (?Init@Main@@SAXHPAPAD@Z)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilDeleteImages@8 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilGetData@0 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilConvertImage@8 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilGetInteger@4 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilLoadImage@4 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilBindImage@4 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol __imp__ilGenImages@8 referenced in function "public: static void __cdecl Main::DisplayScene(void)" (?DisplayScene@Main@@SAXXZ)
1>C:\Users\xxxx\Desktop\Final Year Project 0.2\Debug\Final Year Project.exe : fatal error LNK1120: 8 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.93
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

由于您添加了构建输出,现在答案很简单:您的链接器错误与 DevIL 完全无关。

您需要链接到SDL http://www.libsdl.org/(简单的 DirectMedia 层)。

由于 SDL 具有 C 接口,并且 - IIRC - 不要求 DLL 使用与应用程序相同的堆,因此VC8版本的《开发库》 http://www.libsdl.org/release/SDL-devel-1.2.14-VC8.zip应该没问题(即使你使用 VC10)。只需添加SDL.lib到“附加依赖项”,你应该没问题。


EDIT

好的。 你要么

  1. 未链接所需的 .lib 文件(DevIL.lib 等)或
  2. 链接损坏/错误的 .lib 文件

至少我想不到其他的解释。 构建日志中提到的名称(__imp__ilInit@0等)是正确的,当前的“DevIL SDK”(适用于 32 位 Windows 的 DevIL 1.7.8 SDK http://downloads.sourceforge.net/openil/DevIL-SDK-x86-1.7.8.zip)与 VC10 配合良好(我刚刚验证过)。

为了确保您链接到 DevIL.lib 等,请将以下内容放入您的 main.cpp 文件中:

#pragma comment(lib, "DevIL.lib")
#pragma comment(lib, "ILU.lib")
#pragma comment(lib, "ILUT.lib")

为了确保链接到这些文件的正确版本,请重新下载整个 SDK 并使用新文件重试。


EDIT 2

既然我得到了一半的奖励,我觉得我应该更有帮助:)

您可以尝试的最后一件事:启用详细链接器输出以检查链接器是否找到正确的版本DevIL.lib。 (如果没有找到任何DevIL.lib,你会得到一个错误LNK1104: cannot open file 'DevIL.lib'- 由于您没有收到该消息,因此这不可能是问题所在。)

要启用详细链接器输出,请添加/VERBOSE开关(在配置设置 -> 链接器 -> 命令行 -> 其他选项下)。

这会给你大量的消息。将它们复制到您最喜欢的编辑器中,然后搜索包含以下内容的行DevIL.lib。其中一行应为Searching X:\path\to\DevIL.lib:- 这是副本的路径DevIL.lib链接器正在使用。如果这不是您从下载的 SDK 中复制文件的路径,则您已发现问题。

如果没有包含以下内容的行DevIL.lib,那么链接器甚至不会尝试找到它。然而我从未见过#pragma comment失败,所以如果你确实添加了这些行,那么几乎肯定不会出现这种情况。

顺便说一句:如果您设法解决了这个问题,请告诉我。这太奇怪了,我真的很想知道发生了什么事:)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

DevIL 库文件和依赖项 的相关文章

随机推荐