好吧,事情是这样的。我有我需要的所有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;所以,依赖是存在的,我知道这不是问题所在。
在这之后,我仍然收到链接器错误,主要是所有IL函数的LNK2019:unresolved external symbol__imp_错误。
我遗漏了什么?在我看来,这可能与项目属性或文件有关,themselves...maybe我遗漏了一个文件?
编辑:以下是输出消息
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 ==========发布于 2011-04-29 05:24:05
既然您添加了构建输出,现在答案就很简单了:您的链接器错误与DevIL无关。
您需要链接到SDL (简单DirectMedia层)。
因为SDL有一个C接口,并且- IIRC -不要求DLL使用与应用程序相同的堆,所以VC8 version of the "Development Libraries"应该做得很好(即使您使用VC10)。只需将SDL.lib添加到“附加依赖项”中,就可以了。
编辑
好的。你要么是
至少我想不出其他的解释。构建日志中提到的名称(__imp__ilInit@0等)都是正确的,并且当前的"DevIL SDK“(DevIL 1.7.8 SDK for 32-bit Windows)在VC10上工作得很好(我刚刚验证过了)。
为了确保链接到DevIL.lib等,请在main.cpp文件中放入以下内容:
#pragma comment(lib, "DevIL.lib")
#pragma comment(lib, "ILU.lib")
#pragma comment(lib, "ILUT.lib")要确保链接到这些文件的正确版本,请重新下载整个SDK,然后使用新文件重试。
编辑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失败,所以如果你真的添加了这些行,那几乎肯定不是这样的。
顺便说一句:如果你解决了这个问题,请让我知道。这太奇怪了,我真的很想知道发生了什么:)
发布于 2011-04-21 20:12:19
您需要告诉链接器链接到IL库。
项目设置,链接器,输入
确保库所在的目录也在其他目录字段中。
发布于 2011-05-03 00:02:06
我已经注意到你的config.h.in文件应该有.win扩展名,因为它在DevIL SDK-x86-1.7.8.zip包中。而且也没有devil_cpp_wrapper.h文件。
最后我用这样的方式解决了这个问题:
转到VC include目录-所有目录都在一个名为IL的目录中(默认情况下为c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\IL\ )
转到lib目录(默认情况下为c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\ )
转到项目目录(在本例中为...\Project文件夹\Project1\)
然后,我通过右键单击project->Properties->Linker->Input->Additional依赖项(只写了库文件的名称,如ILU.lib),将库文件添加到项目中
在我的项目中,我只包含了IL\il.h、IL\ilu.h和IL\ilut.h
我想你可能弄错文件了.
https://stackoverflow.com/questions/5743235
复制相似问题