2011-04-13 26 views
14

Como mi búsqueda de una plataforma/biblioteca multiplataforma se puso en marcha, se mencionó muchas veces GLFW. Entonces, decidí probarlo. Ahora, parece que no puedo ni abrir una ventana. : -/GLFW - Error al abrir una ventana

 
#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); 
} 

I escrito esto en MVC++ 2010, vinculada la cabecera, y 2 archivos lib (y tenía 1 archivo DLL, por lo que arrojó que en la carpeta SysWOW64), y me sale estos errores:

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 ========== 

Entiendo los primeros con los colores aleatorios, pero los que siguen a continuación no tienen sentido para mí. ¿Alguna idea de lo que está mal con esto?

Estoy bastante seguro de haber enlazado las libretas correctamente. Los coloco en el directorio C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC \ lib e incluso los vinculé a mi C: \ SDK \ GLFW \ glfw-2.7.bin.WIN32 \ lib-msvc100 directorio \ debug

El paquete GLFW era un archivo .zip, así que lo extraje a mi carpeta SDK predeterminada (para todas mis API y otras cosas). Entonces C: \ SDK \ GLFW es mi predeterminado para GLFW.

Respuesta

44

Necesitas hacer un enlace a opengl32.lib.

igual: Linking to extra libs in Visual Studio

excepto con opengl32.lib.

editar: Debo señalar que no necesita hacer nada excepto agregar opengl32.lib. Esa otra cosa es irrelevante. Además, si ambos están presentes, intente intercambiar el pedido, lo cual es importante en algunos casos.

+0

enlace a opengl32.lib excepto con opengl32.lib? Es lo mismo. : P Pero gracias! ¡Funcionó ahora! : D – Imnotanerd

+1

Oh, no, me refería a la imagen cuando dije eso. Puse la imagen como una demostración, pero como no tengo VS en esta computadora, no pude tomar una captura de pantalla. –

+0

Muy bien, gracias por su ayuda (y consejo)! – Imnotanerd

Cuestiones relacionadas