21

クロスプラットフォームのフレームワーク/ライブラリを探しているうちに、GLFW が何度も言及されました。それで、私はそれを試してみることにしました。今、ウィンドウを初期化することさえできないようです。:-/

#含む
#含む
#含む

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

    if (!glfwInit())
        終了 (EXIT_FAILURE);

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

    しながら(走っている)
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glClearColor(rand() % 255 + 1, rand() % 255 + 1, rand() % 255 + 1, 0);

        glfwSwapBuffers();

        実行中 = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
    }

    glfwTerminate();

    終了 (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\debug ディレクトリにリンクしました。 .

GLFW パッケージは .zip ファイルだったので、デフォルトの SDK フォルダー (すべての API やその他のもの) に解凍しました。したがって、C:\SDK\GLFW が私の GLFW のデフォルトです。

4

1 に答える 1

59

にリンクする必要がありますopengl32.lib

そのためには、下の図のように、Project Settingそこに移動しLinker > input > Additional Dependenciesて追加します (異なるライブラリを分離するためにopengl32.lib使用します)。;

opengl32.lib実際にファイルをどこかに置く必要はないことに注意してください。Visual Studio はそれを見つける場所を知っています。

Visual Studio での追加のライブラリへのリンク

編集: を追加する以外は何もする必要がないことに注意してくださいopengl32.lib。その他のものは無関係です。さらに、両方が存在する場合は、順序を入れ替えてみてください。これは場合によっては重要です。

于 2011-04-13T00:38:03.213 に答える