我在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)

最佳答案

看起来您正在混合使用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的 header ,尽管这可能不太重要。

10-08 08:32