2011-04-13 15 views
14

चूंकि क्रॉस-प्लेटफार्म ढांचे/पुस्तकालय की प्रगति में मेरी प्रगति चल रही है, जीएलएफडब्ल्यू का कई बार उल्लेख किया गया था। तो, मैंने इसे आजमाने का फैसला किया। अब, ऐसा लगता है कि मैं एक खिड़की भी नहीं लगा सकता। : -/जीएलएफडब्ल्यू - एक विंडो खोलने में विफल

 
#include 
#include 
#include 

int main(int argc, char *argv[]) 
{ 
    int running = GL_TRUE; 
    srand(time(NULL)); 

    if (!glfwInit()) 
     exit(EXIT_FAILURE); 

    if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) 
    { 
     glfwTerminate(); 
     exit(EXIT_FAILURE); 
    } 

    while (running) 
    { 
     glClear(GL_COLOR_BUFFER_BIT); 
     glClearColor(rand() % 255 + 1, rand() % 255 + 1, rand() % 255 + 1, 0); 

     glfwSwapBuffers(); 

     running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); 
    } 

    glfwTerminate(); 

    exit(EXIT_SUCCESS); 
} 

मैं MVC++ 2010 में यह लिखा हो, शीर्ष लेख, और 2 lib फ़ाइलें जुड़ा हुआ है (और यह 1 DLL फ़ाइल था, इसलिए मैं SysWOW64 फ़ोल्डर में डाल दिया है कि), और मैं इन त्रुटियों को मिलता है:

1>------ Build started: Project: glfwTest, Configuration: Debug Win32 ------ 
1> test.cpp 
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(8): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data 
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data 
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data 
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data 
1>test.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main 
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol [email protected] 
1>test.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main 
1>GLFW.lib(window.obj) : error LNK2001: unresolved external symbol [email protected] 
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol [email protected] 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function _initWGLExtensions 
1>GLFW.lib(win32_glext.obj) : error LNK2001: unresolved external symbol [email protected] 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function _createWindow 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function _createContext 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function _destroyWindow 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function __glfwPlatformSetWindowSize 
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function __glfwPlatformSetWindowSize 
1>GLFW.lib(glext.obj) : error LNK2001: unresolved external symbol [email protected] 
1>GLFW.lib(glext.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function __glfwParseGLVersion 
1>c:\users\andrew\documents\visual studio 2010\Projects\glfwTest\Debug\glfwTest.exe : fatal error LNK1120: 9 unresolved externals 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

मैं यादृच्छिक रंगों के साथ पहले कुछ को समझता हूं, लेकिन उसके बाद वाले लोगों को मुझे कोई समझ नहीं आती है। कोई विचार यह क्या गलत है?

मुझे पूरा यकीन है कि मैंने libs को सही तरीके से लिंक किया है। मैं उन्हें सी: \ प्रोग्राम फ़ाइलें (x86) \ Microsoft Visual Studio 10.0 \ VC \ lib निर्देशिका में रखता हूं और उन्हें अपने सी: \ SDK \ GLFW \ glfw-2.7.bin.WIN32 \ lib-msvc100 से भी लिंक करता है \ डीबग निर्देशिका।

जीएलएफडब्ल्यू पैकेज एक .zip फ़ाइल था, इसलिए मैंने इसे अपने डिफ़ॉल्ट एसडीके फ़ोल्डर (मेरे सभी एपीआई और अन्य सामानों के लिए) में निकाला। तो सी: \ एसडीके \ जीएलएफडब्ल्यू जीएलएफडब्ल्यू के लिए मेरा डिफ़ॉल्ट है।

उत्तर

44

आपको opengl32.lib से लिंक करने की आवश्यकता है।

तरह: Linking to extra libs in Visual Studio

opengl32.lib साथ छोड़कर

संपादित करें: मुझे ध्यान रखना चाहिए कि आपको opengl32.lib को छोड़कर कुछ भी करने की आवश्यकता नहीं है। वह अन्य सामान अप्रासंगिक है। इसके अतिरिक्त, यदि दोनों मौजूद हैं, तो ऑर्डर को स्वैप करने का प्रयास करें, जो कुछ मामलों में मायने रखता है।

+0

opengl32.lib के अलावा opengl32.lib को छोड़कर लिंक? एक ही बात है। : पी लेकिन धन्यवाद! यह अब काम किया! : डी – Imnotanerd

+1

ओह, नहीं - जब मैंने कहा कि मैं तस्वीर का जिक्र कर रहा था। मैंने तस्वीर को एक प्रदर्शन के रूप में रखा, लेकिन चूंकि मेरे पास इस कंप्यूटर पर वीएस नहीं है, इसलिए मैं खुद को एक स्क्रीनशॉट नहीं ले सका। –

+0

ठीक है, आपकी मदद के लिए धन्यवाद (और सलाह)! – Imnotanerd