OpenGL GLut 与 Windows 8 64 位上的 Visual Studio 2013 链接问题
OpenGL GLut linking issues with Visual Studio 2013 on Windows 8 64bit
首先,我从这个来源下载了glut,http://user.xmission.com/~nate/glut.html">Nate Robins。 我把: glut32.dll into C:\Windows\SysWOW64, glut32.lib into C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib glut.h into C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL
在Visual Studio中,在C++下我创建了一个空项目,将编译器更改为64x。 我确保选择所有配置并链接opengl32.lib,glu32.lib和glut32.lib。
在"工具"-">"选项"->"VC++ 目录"->"包含文件:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include在"配置属性"→链接器→其他库目录中:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib
/************************************
* Handout: example.cpp
*
* This program is to demonstrate the basic OpenGL program structure.
* Read the comments carefully for explanations.
************************************/
#define WINDOWS 1 /* Set to 1 for Windows, 0 else */
#define UNIX_LINUX 0 /* Set to 1 for Unix/Linux, 0 else */
#if WINDOWS
#include <windows.h>
#include <GL/glut.h>
#endif
#if UNIX_LINUX
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <stdio.h>
#include <math.h>
float f = 0.0;
void display(void);
void my_init(void);
void reshape(int w, int h);
void idle(void);
void main(int argc, char **argv)
{
/*---- Initialize & Open Window ---*/
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // double-buffering and RGB color
// mode.
glutInitWindowSize(500, 500);
glutInitWindowPosition(30, 30); // Graphics window position
glutCreateWindow("Rectangle"); // Window title is "Rectangle"
/*--- Register call-back functions; any order is fine ---*/
/* Events: display, reshape, keyboard, mouse, idle, etc.
- display: Automatically called when the window is first opened.
Later, when the frame content needs to be changed, we need
to call display again From the Program to re-draw the objects.
This is essential for animation.
- reshape: Automatically called when the window is first opened,
or when the window is re-sized or moved by the user.
- keyboard: Automatically called when a keyboard event occurs.
- mouse: Automatically called when a mouse event occurs.
- idle: Automatically called when nothing occurs.
This is essential for animation.
* Once entering the event loop, the execution control always returns to
the event loop. When particular event occurs, the corresponding call-back
function is called; when that call-back function finishes, control again
goes back to the event loop, and the process is repeated.
*/
glutDisplayFunc(display); // Register our display() function as the display
// call-back function
glutReshapeFunc(reshape); // Register our reshape() function as the reshape
// call-back function
// glutMouseFunc(mouse); // for mouse
// glutKeyboardFunc(key); // for keyboard
glutIdleFunc(idle); // Register our idle() function
my_init(); // initialize variables
glutMainLoop(); // Enter the event loop
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); // clear frame buffer (also called the
// color buffer)
glColor3f(0.0, 1.0, 1.0); // draw in cyan.
// The color stays the same until we
// change it next time.
glBegin(GL_POLYGON); // Draw a polygon (can have many vertices)
// The vertex coordinates change by different
// values of i; see also function idle().
glVertex2f(100, 100 + f);
glVertex2f(200, 100 + f);
glVertex2f(200, 300 + f);
glVertex2f(100, 300 + f);
glEnd();
glFlush(); // Render (draw) the object
glutSwapBuffers(); // Swap buffers in double buffering.
}
void my_init()
{
glClearColor(0.0, 0.0, 0.0, 0.0); // Use black as the color for clearing
// the frame buffer (also called the
// color buffer). This produces a
// black background.
}
void reshape(int w, int h)
{
glViewport(0, 0, w, h); // Viewport within the graphics window.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
}
void idle(void)
{
f += 0.02; // smaller number gives a slower but smoother animation
if (f > 180.0) f = 0.0;
glutPostRedisplay(); // or call display()
}
我的错误是
Error 17 error LNK1120: 16 unresolved externals C:ProjectsProject1x64DebugProject1.exe Project1
Error 15 error LNK2001: unresolved external symbol _fltused C:ProjectsProject1Project1main.obj Project1
Error 13 error LNK2001: unresolved external symbol _RTC_InitBase C:ProjectsProject1Project1main.obj Project1
Error 14 error LNK2001: unresolved external symbol _RTC_Shutdown C:ProjectsProject1Project1main.obj Project1
Error 16 error LNK2001: unresolved external symbol mainCRTStartup C:ProjectsProject1Project1LINK Project1
Error 7 error LNK2019: unresolved external symbol __imp___glutCreateWindowWithExit referenced in function glutCreateWindow_ATEXIT_HACK C:ProjectsProject1Project1main.obj Project1
Error 2 error LNK2019: unresolved external symbol __imp___glutInitWithExit referenced in function glutInit_ATEXIT_HACK C:ProjectsProject1Project1main.obj Project1
Error 1 error LNK2019: unresolved external symbol __imp_exit referenced in function glutInit_ATEXIT_HACK C:ProjectsProject1Project1main.obj Project1
Error 10 error LNK2019: unresolved external symbol __imp_glutDisplayFunc referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 12 error LNK2019: unresolved external symbol __imp_glutIdleFunc referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 3 error LNK2019: unresolved external symbol __imp_glutInitDisplayMode referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 4 error LNK2019: unresolved external symbol __imp_glutInitWindowPosition referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 5 error LNK2019: unresolved external symbol __imp_glutInitWindowSize referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 6 error LNK2019: unresolved external symbol __imp_glutMainLoop referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 8 error LNK2019: unresolved external symbol __imp_glutPostRedisplay referenced in function "void __cdecl idle(void)" (?idle@@YAXXZ) C:ProjectsProject1Project1main.obj Project1
Error 11 error LNK2019: unresolved external symbol __imp_glutReshapeFunc referenced in function main C:ProjectsProject1Project1main.obj Project1
Error 9 error LNK2019: unresolved external symbol __imp_glutSwapBuffers referenced in function "void __cdecl display(void)" (?display@@YAXXZ) C:ProjectsProject1Project1main.obj Project1
无法弄清楚我做错了什么。
您使用的是 32 位库,但您正在编译 x64 可执行文件,并且链接器无法解析这些符号。
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何在MS Visual Studio 2019中运行QT UI
- 如何使用Visual Studio 2017在C++中为参数化对象数组使用唯一指针
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio 2019:插入多个C++风格的单行注释
- Visual Studio Code "undefined reference to `WinMain@16'"
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- Visual Studio中的函数声明和函数定义问题
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- Visual Studio mkl_link_tool.exe链接错误
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 不同的Visual Studio版本中缺少.dll
- 用Visual Studio在C++中嵌入Julia
- Visual Studio 2017循环自动向量化问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- Visual Studio在尝试读取resource.txt文件时崩溃
- Visual Studio 2017 不允许我创建 C++ 专用模板