2016-01-01 174 views
1

我想在C++中構建一個OpenGL應用程序。我使用glew和glfw庫。現在,我想創造一些紋理,但現在它說:OpenGL鏈接問題

1>model.obj : error LNK2019: unresolved external symbol __imp_glBindTexture referenced in function "public: void __cdecl Texture::Bind(unsigned int)" ([email protected]@@[email protected]) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glGenTextures referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@QEAA_NXZ) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexImage2D referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@QEAA_NXZ) 
1>model.obj : error LNK2019: unresolved external symbol __imp_glTexParameterf referenced in function "public: bool __cdecl Texture::Load(void)" ([email protected]@@QEAA_NXZ) 
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib\magickdb.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64' 
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib\magickrl.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64' 
1>C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\x64\Debug\OpenGLTest3.exe : fatal error LNK1120: 16 unresolved externals 

一切工作至今(glGenVertexArrays(),(4,8)等),只紋理函數(glGenTextures(),glBindTexture()等)不起作用。 接頭是建立這樣的:glew32.lib;glfw3.lib;assimp.lib;devil.lib;magickdb.lib;magickrl.lib;%(AdditionalDependencies)

VC包括DIR: C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\include;$(IncludePath) VC lib目錄: C:\Users\Dynamitos5\Documents\cuda\OpenGLTest\external\lib;$(LibraryPath)

+0

你是否缺少opengl32.lib? – BDL

+0

@BDL我認爲opengl32.lib只適用於已棄用的OpenGL1.1內容。我的錯誤理解/ _ \。我會接受它,如果你把它作爲回答 – Dynamitos

回答

3

所有功能到OpenGL的1.1直接在opengl32.lib庫中實現。所有其他功能都可以通過擴展使用,並且必須手動加載(或使用像glew這樣的庫)。

對您而言,您錯過了重新鏈接opengl32.lib

0

這裏有一些事情...... OpenGL隨Windows一起提供,但只能使用OpenGL 1.1和opengl32.lib。因此,所有後續OpenGL版本都需要擴展庫(如glew)。現在,freeglut包含了opengl32.lib,但是glew沒有,所以如果你使用的是glew,你必須自己包含opengl32.lib。在Visual Studio下,右鍵單擊您的項目(粗體),然後在Properties/Linker/Input中添加openg32.lib。無需在C/C++/General或Linker/General中添加任何其他目錄 - opengl32.lib隨Windows一起提供,Visual Studio知道在哪裏可以找到它,但仍需要被告知與它鏈接!最後,在可執行文件所在的Visual Studio Debug目錄中複製相應的動態庫,例如freeglut.dll或glew32.dll。

+0

GLUT/freeglut不是擴展裝載機。他們管理窗口,上下文和事件。 – derhass