GLFW - Не удалось открыть окно - PullRequest
16 голосов
/ 13 апреля 2011

Поскольку моя охота на кроссплатформенную инфраструктуру / библиотеку продолжалась, GLFW упоминался много раз. Итак, я решил попробовать это. Теперь кажется, что я даже не могу открыть окно. : - /

#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 __imp__glClearColor@16 referenced in function _main
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClearColor@16
1>test.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
1>GLFW.lib(window.obj) : error LNK2001: unresolved external symbol __imp__glClear@4
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClear@4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglGetProcAddress@4 referenced in function _initWGLExtensions
1>GLFW.lib(win32_glext.obj) : error LNK2001: unresolved external symbol __imp__wglGetProcAddress@4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function _createWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function _createContext
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function _destroyWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(glext.obj) : error LNK2001: unresolved external symbol __imp__glGetIntegerv@8
1>GLFW.lib(glext.obj) : error LNK2019: unresolved external symbol __imp__glGetString@4 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 ==========

Я понимаю первые несколько со случайными цветами, но те, что после этого, не имеют смысла для меня. Есть идеи, что с этим не так?

Я почти уверен, что правильно связал библиотеки. Я помещаю их в C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC \ lib каталог и даже связал их с моим C: \ SDK \ GLFW \ glfw-2.7.bin.WIN32 \ lib-msvc100 \ каталог отладки.

Пакет GLFW представлял собой файл .zip, поэтому я просто распаковал его в папку SDK по умолчанию (для всех моих API и прочего). Поэтому C: \ SDK \ GLFW - это мой стандарт по умолчанию для GLFW.

1 Ответ

46 голосов
/ 13 апреля 2011

Вам нужно ссылку на opengl32.lib.

Как: Linking to extra libs in Visual Studio

кроме как с opengl32.lib.

edit: Я должен отметить, что вам ничего не нужно делать, кроме как добавить opengl32.lib. Этот другой материал не имеет значения. Кроме того, если оба присутствуют, попробуйте поменять местами порядок, который имеет значение в некоторых случаях.

...