Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Windows 8 64位上Visual Studio 2013的OpenGL GLut链接问题_C++_Visual Studio_Opengl - Fatal编程技术网

C++ Windows 8 64位上Visual Studio 2013的OpenGL GLut链接问题

C++ Windows 8 64位上Visual Studio 2013的OpenGL GLut链接问题,c++,visual-studio,opengl,C++,Visual Studio,Opengl,首先我从这个来源下载了glut,http://user.xmission.com/~nate/glut.html“>内特·罗宾斯。我说: 将glut32.dll转换为C:\Windows\SysWOW64, glut32.lib转换为C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\lib glut.h转换为C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\include\GL 在

首先我从这个来源下载了glut,http://user.xmission.com/~nate/glut.html“>内特·罗宾斯。我说: 将glut32.dll转换为C:\Windows\SysWOW64, glut32.lib转换为C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\lib glut.h转换为C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\include\GL

在VisualStudio中,在C++下,我创建了一个空的项目,将编译器改为64×x。我确定选择所有的配置并链接OpenGL32.LIB、GL32.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()
}

无法找出我做错了什么。

您使用的是32位库,但您正在编译x64可执行文件,而链接器无法解析符号。

您使用的是32位库,但您正在编译x64可执行文件,而链接器无法解析符号。

@Bokucius我下载的文件说是64位的。这是否意味着即使我的C:\Windows\SysWOW64中有一个opengl32.dll,我仍然需要用win32编译它?SysWOW64用于32位dll(),在您提供的url中显示“GLUT for win32”“现在我明白了。谢谢。@Bokucius我下载的文件说是64位的。这是否意味着即使我的C:\Windows\SysWOW64中有一个opengl32.dll,我仍然需要用win32编译它?SysWOW64是用于32位dll(),您提供的url中写着“GLUT for win32”,我现在明白了。谢谢
Error   17  error LNK1120: 16 unresolved externals  C:\Projects\Project1\x64\Debug\Project1.exe Project1
Error   15  error LNK2001: unresolved external symbol _fltused  C:\Projects\Project1\Project1\main.obj  Project1
Error   13  error LNK2001: unresolved external symbol _RTC_InitBase C:\Projects\Project1\Project1\main.obj  Project1
Error   14  error LNK2001: unresolved external symbol _RTC_Shutdown C:\Projects\Project1\Project1\main.obj  Project1
Error   16  error LNK2001: unresolved external symbol mainCRTStartup    C:\Projects\Project1\Project1\LINK  Project1
Error   7   error LNK2019: unresolved external symbol __imp___glutCreateWindowWithExit referenced in function glutCreateWindow_ATEXIT_HACK  C:\Projects\Project1\Project1\main.obj  Project1
Error   2   error LNK2019: unresolved external symbol __imp___glutInitWithExit referenced in function glutInit_ATEXIT_HACK  C:\Projects\Project1\Project1\main.obj  Project1
Error   1   error LNK2019: unresolved external symbol __imp_exit referenced in function glutInit_ATEXIT_HACK    C:\Projects\Project1\Project1\main.obj  Project1
Error   10  error LNK2019: unresolved external symbol __imp_glutDisplayFunc referenced in function main C:\Projects\Project1\Project1\main.obj  Project1
Error   12  error LNK2019: unresolved external symbol __imp_glutIdleFunc referenced in function main    C:\Projects\Project1\Project1\main.obj  Project1
Error   3   error LNK2019: unresolved external symbol __imp_glutInitDisplayMode referenced in function main C:\Projects\Project1\Project1\main.obj  Project1
Error   4   error LNK2019: unresolved external symbol __imp_glutInitWindowPosition referenced in function main  C:\Projects\Project1\Project1\main.obj  Project1
Error   5   error LNK2019: unresolved external symbol __imp_glutInitWindowSize referenced in function main  C:\Projects\Project1\Project1\main.obj  Project1
Error   6   error LNK2019: unresolved external symbol __imp_glutMainLoop referenced in function main    C:\Projects\Project1\Project1\main.obj  Project1
Error   8   error LNK2019: unresolved external symbol __imp_glutPostRedisplay referenced in function "void __cdecl idle(void)" (?idle@@YAXXZ)   C:\Projects\Project1\Project1\main.obj  Project1
Error   11  error LNK2019: unresolved external symbol __imp_glutReshapeFunc referenced in function main C:\Projects\Project1\Project1\main.obj  Project1
Error   9   error LNK2019: unresolved external symbol __imp_glutSwapBuffers referenced in function "void __cdecl display(void)" (?display@@YAXXZ)   C:\Projects\Project1\Project1\main.obj  Project1