使用MinGW未定义对DevIL函数的引用

我在C ++连接,静态和dynamic,.lib和.a等方面都不是很有经验。

注意下面我有-l所有的DevIL库(DevIL,ILU,ILUT)。 至于库文件,我把DLL的System32和SysWOW64和MinGW \ lib中的.libs。 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的头文件,尽管这可能不那么重要。