1
votes

First I downloaded glut from this source, http://user.xmission.com/~nate/glut.html"> Nate Robins. I put: 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

In Visual Studio, under C++ I created an empty project, changed the compiler to 64x. I made sure to select ALL Configurations and linked opengl32.lib,glu32.lib and glut32.lib.

In Tools -> Options -> VC++ Directories -> Include Files:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include In Configuration Properties → Linker → Additional Library Directories: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()
}

My errors are

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

Cannot figure out what I'm doing wrong.

1

1 Answers

6
votes

You are using 32bit libraries but you are compiling a x64 executable and the linker cannot resolve the symbols.