1

我在 C++ 链接、静态与动态、.lib 与 .a 等方面不是很有经验。

请注意,下面我对所有 DevIL 库(DevIL、ILU、ILUT)都有 -l。至于库文件,我将 dll 放在 System32 和 SysWOW64 中,并将 .libs 放在 MinGW\lib 中。Eclipse 项目的“当前工具链”确实是 MinGW GCC。该项目只有 1 个源文件 facecube.cpp(有 main())。我错过了什么?

包括:

#include "Angel.h"
#include <IL\config.h>
#include <IL\ilut_config.h>
#include <IL\il.h>
#include <IL\ilu.h>
#include <IL\ilut.h>
#include <iostream>
using namespace std;

编译器输出:

16:50:49 **** Rebuild of configuration Release for project TextureCube ****
Info: Internal Builder is used for build
g++ -DGLEW_STATIC "-IC:\\Users\\Brent\\Desktop\\angel_code\\include" "-IC:\\Users\\Brent\\Desktop\\6631AdvGraphics\\4631_HW4_brent_barre\\include" -O3 -Wall -c -fmessage-length=0 -o facecube.o "..\\facecube.cpp" 
In file included from ..\facecube.cpp:7:0:
C:\Users\Brent\Desktop\6631AdvGraphics\4631_HW4_brent_barre\include/IL/ilut.h:333:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
C:\Users\Brent\Desktop\6631AdvGraphics\4631_HW4_brent_barre\include/IL/ilut.h:334:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
C:\Users\Brent\Desktop\6631AdvGraphics\4631_HW4_brent_barre\include/IL/ilut.h:356:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
..\facecube.cpp: In function 'void quad(int, int, int, int)':
..\facecube.cpp:56:12: warning: unused variable 'colors' [-Wunused-variable]
..\facecube.cpp: In function 'void init()':
..\facecube.cpp:129:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
..\facecube.cpp:130:39: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
In file included from C:\Users\Brent\Desktop\angel_code\include/Angel.h:75:0,
                 from ..\facecube.cpp:6:
C:\Users\Brent\Desktop\angel_code\include/CheckError.h: At global scope:
C:\Users\Brent\Desktop\angel_code\include/CheckError.h:37:1: warning: 'void _CheckError(const char*, int)' defined but not used [-Wunused-function]
g++ -DGLEW_STATIC "-IC:\\Users\\Brent\\Desktop\\angel_code\\include" "-IC:\\Users\\Brent\\Desktop\\6631AdvGraphics\\4631_HW4_brent_barre\\include" -O3 -Wall -c -fmessage-length=0 -o "Common\\InitShader.o" "..\\Common\\InitShader.cpp" 
In file included from C:\Users\Brent\Desktop\angel_code\include/Angel.h:75:0,
                 from ..\Common\InitShader.cpp:2:
C:\Users\Brent\Desktop\angel_code\include/CheckError.h:37:1: warning: 'void _CheckError(const char*, int)' defined but not used [-Wunused-function]
g++ -o TextureCube.exe facecube.o "Common\\InitShader.o" -lfreeglut -lglew32 -lopengl32 -lwinmm -lgdi32 -lDevIL -lILU -lILUT 
facecube.o:facecube.cpp:(.text+0x53f): undefined reference to `__imp__ilInit@0'
facecube.o:facecube.cpp:(.text+0x545): undefined reference to `__imp__iluInit@0'
facecube.o:facecube.cpp:(.text+0x54b): undefined reference to `__imp__ilutInit@0'
facecube.o:facecube.cpp:(.text+0x558): undefined reference to `__imp__ilutRenderer@4'
facecube.o:facecube.cpp:(.text+0x566): undefined reference to `__imp__ilutGLLoadImage@4'
collect2.exe: error: ld returned 1 exit status

16:50:50 Build Finished (took 1s.38ms)

上面忽略的编译指示警告的代码(似乎与我无关):

333 #pragma warning(push)
334 #pragma warning(disable : 4115)  // Disables 'named type definition in parentheses' warning
...
356 #pragma warning(pop)
4

1 回答 1

1

看起来您正在混合使用 32 位和 64 位模块。具体来说,当我编译一个 32 位程序但链接到 64 位 DevIL 库时,我会遇到同样的问题。

确保您已下载并链接到 DevIL-SDK-x86-1.7.8 SDK ( http://downloads.sourceforge.net/project/openil/DevIL%20Windows%20SDK/1.7.8/DevIL-SDK- x86-1.7.8.zip )。您还应该确保您使用的是来自相应 SDK 的标头,尽管这可能不太重要。

于 2012-11-11T08:40:01.823 回答