Arrgh openGL!

Started by
8 comments, last by dougbinks 10 years, 11 months ago

I'm having real trouble setting up openGL in windows.

Why can't I just open a console application and link in GLUT or freeGLUT and GLEW. I've tried 4 tutorials and gotten non complile errors on all of them.

What am I doing wrong, I thought swapping to openGL so I could port to all platforms would be a good idea but i'm having reservations now.

Why can't I just link freeGlut in the linker in Visual studio 10? or alternatively:

#include <GL/glew.h>
#include <GL/wglew.h>
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "opengl32.lib")

Any help will greatly increase the number of folicles left in my head at the end of the day!

If you get near a point, make it!
Advertisement
Clearly your problem is that you didn't stick your tongue out far enough or use the right curse words.

Specifics, man. Instead of just vague ranting, post specifics: error messages, what you are doing, what you have tried, etc...

Porting to all platforms is a lot more complicated than just switching to OpenGL, by the way.

Yeah good point, but literally getting a basic window running on windows seems to be a nightmare.

Running the code from the intro link (http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html):

#include <stdlib.h>
#include <GL/glew.h>
#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif
#include <stdio.h>
static int make_resources(void)
{
return 1;
}
/*
* GLUT callbacks:
*/
static void update_fade_factor(void)
{
}
static void render(void)
{
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}
/*
* Entry point
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(400, 300);
glutCreateWindow("Hello World");
glutIdleFunc(&update_fade_factor);
glutDisplayFunc(&render);
glewInit();
if (!GLEW_VERSION_2_0) {
fprintf(stderr, "OpenGL 2.0 not available\n");
return 1;
}
if (!make_resources()) {
fprintf(stderr, "Failed to load resources\n");
return 1;
}
glutMainLoop();
return 0;
}
Receiving:
LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
P.S. this is as a console application opened in Visual Studio 10
If you get near a point, make it!

I have used freeglut and GLEW in several Windows projects without any problem. They are actually a lot easier to install than most libraries in my experience. Some things to check:

1. Have you added the directories of GLEW and freeglut to your project?

2. Have you actually checked that those directories contain the libraries (and the include files) you are trying to link (and include)?

3. Have you included the directories containing the dynamic libraries to your PATH?

This is the bit i really don't understand, why it is so difficult to just link to files/folders.

Why can't I just copy them to the project directory and then define it at the beginning, or can I and I haven't found out how.

Do I set the includes in the Linker->Input->file... section, or VC++ Directories->Includes directories. Or does it have to be both!?

If you get near a point, make it!

3. Have you included the directories containing the dynamic libraries to your PATH?

Is this the Linker->Input section?

Where I would place:

glew32.lib
opengl32.lib

If you get near a point, make it!

You should have a directory with all of your .lib files in it. Then, in the project properties (make sure you do this for Release and Debug), put that directory in to Linker->General->Additional Library Directories. The directory you give should be relative to the .vcproj file (or absolute), or another option is to use the built-in VS macros to define it relative to your solution directory by doing something like "$(SolutionDir)../lib;". Then head over to Linker->Input->Additional Dependencies and list your .lib files spearated by semicolons (or one per line if you use the drop-down menu and hit the <Edit...> option) . Make sure to hit "Apply" at the bottom right instead of just pressing "Ok". Example for the Additional dependencies, part of mine looks like "glew32.lib;opengl32.lib;glu32.lib;"

opengl32.lib should be provided by the system, so you don't have to give a specific directory for that, you should just be able to add it to the Additional Dependencies.

(make sure you do this for Release and Debug) - Do you mean when the code is finished? Is this best practice for when it is sent out to joe public?

The directory you give should be relative to the .vcproj file (or absolute) - So in the same folder as the .vcproj file basically?

Thanks for the advise btw, I appreciate the help.

If you get near a point, make it!

Dumped all the .lib files into a folder called \myIncludes, added it in Linker->General->Additional Library Directories.

It's still throwing LINK : fatal error LNK1104: cannot open file 'glut32.lib'

It's now rid itself of the freeglut error & swapped it for glut32.lib now lol.

If you get near a point, make it!

You may find this basic example project helpful: https://github.com/dougbinks/glewfw - it doesn't use GLUT or freeglut but instead uses glfw.

This topic is closed to new replies.

Advertisement