这让我发疯,我想在第 4.2.1 节之后静态链接到 GLFW.lib。提供的 readme.html 文件我已将 glfw.lib 和 opengl32.lib 添加到 VS 链接器的附加依赖项部分。
我还将包含 glfw.lib 的目录添加到链接器 > 常规下的附加库目录部分。
当然,我已经在我的项目中包含了 glfw.h 文件,但我仍然得到......
Error 1 error LNK2019: unresolved external symbol _glfwInit referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 2 error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 3 error LNK2019: unresolved external symbol _glfwOpenWindow referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 4 error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 5 error LNK2019: unresolved external symbol _glfwGetWindowParam referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 6 error LNK2019: unresolved external symbol _glfwGetKey referenced in function _main C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Spark\main.obj Spark
Error 7 error LNK1120: 6 unresolved externals C:\Users\Smith_000\Documents\Visual Studio 2012\Projects\Spark\Debug\Spark.exe 1 1 Spark
使用以下(示例)代码...
#include <glfw.h>
#include <stdlib.h>
int main( void )
{
int running = GL_TRUE;
// Initialize GLFW
if( !glfwInit() )
{
exit( EXIT_FAILURE );
}
// Open an OpenGL window
if( !glfwOpenWindow( 300,300, 0,0,0,0,0,0, GLFW_WINDOW ) )
{
glfwTerminate();
exit( EXIT_FAILURE );
}
// Main loop
while( running )
{
// OpenGL rendering goes here...
glClear( GL_COLOR_BUFFER_BIT );
// Swap front and back rendering buffers
glfwSwapBuffers();
// Check if ESC key was pressed or window was closed
running = !glfwGetKey( GLFW_KEY_ESC ) &&
glfwGetWindowParam( GLFW_OPENED );
}
// Close window and terminate GLFW
glfwTerminate();
// Exit program
exit( EXIT_SUCCESS );
}
我究竟做错了什么?