Author Topic: How do you fully install opengl???  (Read 18333 times)

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
How do you fully install opengl???
« on: June 07, 2014, 06:48:21 pm »
I can make a new opengl project just fine, and it brings up the default code with the spinny triangle. So i thought all was well, then i tried pasting some code in from one of these places and got all sorts of errors:

I have tried:
http://en.wikibooks.org/wiki/OpenGL_Programming#The_basics_arc

and

http://www.arcsynthesis.org/gltut/

Every bit of code on those gives a whole bunch of errors, reinstalling codeblocks didnt help, whats the matter?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7576
    • My Best Post
Re: How do you fully install opengl???
« Reply #1 on: June 07, 2014, 11:07:50 pm »
Since you are keeping the errors a secret; we have to assume you are the problem.

NOTE: The next likely candidate is your compiler setup or library installation.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #2 on: June 08, 2014, 04:48:46 pm »
Oh I am a big turnip!

Ok heres the code:

Code
/* Using the standard output for fprintf */
#include <stdio.h>
#include <stdlib.h>
/* Use glew.h instead of gl.h to get all the GL prototypes declared */
#include <glew.h>
/* Using the GLUT library for the base windowing setup */
#include <glut.h>

/* ADD GLOBAL VARIABLES HERE LATER */

int init_resources(void)
{
  /* FILLED IN LATER */
  return 1;
}

void onDisplay()
{
  /* FILLED IN LATER */
}

void free_resources()
{
  /* FILLED IN LATER */
}

int main(int argc, char* argv[])
{
  /* Glut-related initialising functions */
  glutInit(&argc, argv);
  glutInitContextVersion(2,0);
  glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
  glutInitWindowSize(640, 480);
  glutCreateWindow("My First Triangle");

  /* Extension wrangler initialising */
  GLenum glew_status = glewInit();
  if (glew_status != GLEW_OK)
  {
    fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
    return EXIT_FAILURE;
  }

  /* When all init functions run without errors,
  the program can initialise the resources */
  if (1 == init_resources())
  {
    /* We can display it if everything goes OK */
    glutDisplayFunc(onDisplay);
    glutMainLoop();
  }

  /* If the program exits in the usual way,
  free resources and exit with a success */
  free_resources();
  return EXIT_SUCCESS;
}

and here are the errors: http://imgur.com/H2R00O9
(isnt there a way to just COPY AND PASTE the darn text from the build messages screen????????)

I installed glut as like the readme.txt file said:

* Put the .dll in system32 directory
* put the .h file in "CodeBlocks\MinGW\include" and "CodeBlocks\MinGW\include\GL"
* put the .lib "CodeBlocks\MinGW\lib"

Restarted program and the code, and it gives those errors...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How do you fully install opengl???
« Reply #3 on: June 08, 2014, 05:02:52 pm »
(isnt there a way to just COPY AND PASTE the darn text from the build messages screen????????)
Of course there is -> right click copy to clipboard or copy selection to clipboard...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #4 on: June 08, 2014, 05:04:44 pm »
when you click or even "hold-click" on a line, it highlights it all and then the main editor goes to whatever part of your code has the problem... its not selectable text.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How do you fully install opengl???
« Reply #5 on: June 08, 2014, 05:38:32 pm »
Right clicking should do the trick (either in the log itself or on the tab, depending on the OS).
But in any case the "Build log" is more meaningful.

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #6 on: June 08, 2014, 06:00:20 pm »
Ok heres the build log:

Code
-------------- Build: Debug in GL_PROJ (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe  -o bin\Debug\GL_PROJ.exe obj\Debug\main.o   -lopengl32 -lglu32 -lgdi32 "..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\glut32.lib"
obj\Debug\main.o: In function `glutInit_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:486: undefined reference to `__glutInitWithExit'
obj\Debug\main.o: In function `glutCreateWindow_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:503: undefined reference to `__glutCreateWindowWithExit'
obj\Debug\main.o: In function `glutCreateMenu_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:549: undefined reference to `__glutCreateMenuWithExit'
obj\Debug\main.o: In function `main':
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:31: undefined reference to `glutInitContextVersion'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:32: undefined reference to `glutInitDisplayMode'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:33: undefined reference to `glutInitWindowSize'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:37: undefined reference to `_imp__glewInit@0'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:40: undefined reference to `_imp__glewGetErrorString@4'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:49: undefined reference to `glutDisplayFunc'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:50: undefined reference to `glutMainLoop'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
10 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How do you fully install opengl???
« Reply #7 on: June 08, 2014, 06:37:59 pm »
You need to link to glut and glew libraries!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #8 on: June 08, 2014, 06:53:36 pm »
but it looks to me like these are GLUT related errors and i HAVE linked that:



Is there a codeblock download with opengl+glew+glut+everyotheropenglthing already installed and working? and if not can someone make one because this isnt making any sense!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How do you fully install opengl???
« Reply #9 on: June 08, 2014, 10:01:09 pm »
You cannot have full path there, just the name of the file (strip the extension and lib prefix). The path must go in search directories -> linker!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #10 on: June 08, 2014, 10:30:02 pm »
Quote from: oBFusCATed
You cannot have full path there, just the name of the file (strip the extension and lib prefix).
ok I tried just typing in "glut" there, but then it said it couldnt find "-lglut" in the error message. BUT that was the only error message.

I put in glut32 (the actual filename without directory or file extension in it) and it gave the errors.

From the above, if it REALLY couldnt find the file, it would just give the first "cannot find" error message. But it doesnt, it says that lots of commands are unknown but it MUST be finding the file, as it doesnt give the first error message. Should I redownload glut (link please)? did i get a bad version?


Quote from: oBFusCATed
The path must go in search directories -> linker!

I have absolutely no idea what you are talking about here, please explain more.

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How do you fully install opengl???
« Reply #11 on: June 08, 2014, 10:53:28 pm »
You're trying to link with libglut32.lib which is a Visual Studio import library. You're using MinGW. Linking to lib files from gcc sometimes works, sometimes not, depending on the library type. In your case, symbol names in the file seem to be different than the compiler expects. You should link to libglut32.a or a similar lib*.a file. There are tools that convert import libraries.

The easiest solution in your case: download freeglut library (a free GLUT replacement). There are precompiled MinGW binaries linked on the project page, you can also compile the library yourself. Then link your code to freeglut (libfreeglut.a) and it should work.

And your problem is not CodeBlocks related.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How do you fully install opengl???
« Reply #12 on: June 08, 2014, 11:55:51 pm »
MinGW/TDM releases are capable to link directly to DLL, there is no need for an import libraries.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #13 on: June 14, 2014, 06:13:42 pm »
Ok so i downloaded and installed freeglut, no problem, it ran the default code with the spinny red objects, great stuff.... then when trying to use the other code, it wouldnt work:

(this is the very first example code from here: http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction)

Code
/* Using the standard output for fprintf */
#include <stdio.h>
#include <stdlib.h>
/* Use glew.h instead of gl.h to get all the GL prototypes declared */
#include <glew.h>
/* Using the GLUT library for the base windowing setup */
#include <glut.h>
/* ADD GLOBAL VARIABLES HERE LATER */

int init_resources(void)
{
  /* FILLED IN LATER */
  return 1;
}

void onDisplay()
{
  /* FILLED IN LATER */
}

void free_resources()
{
  /* FILLED IN LATER */
}

int main(int argc, char* argv[])
{
  /* Glut-related initialising functions */
  glutInit(&argc, argv);
  glutInitContextVersion(2,0);
  glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
  glutInitWindowSize(640, 480);
  glutCreateWindow("My First Triangle");

  /* Extension wrangler initialising */
  GLenum glew_status = glewInit();
  if (glew_status != GLEW_OK)
  {
    fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
    return EXIT_FAILURE;
  }

  /* When all init functions run without errors,
  the program can initialise the resources */
  if (1 == init_resources())
  {
    /* We can display it if everything goes OK */
    glutDisplayFunc(onDisplay);
    glutMainLoop();
  }

  /* If the program exits in the usual way,
  free resources and exit with a success */
  free_resources();
  return EXIT_SUCCESS;
}

It gives an error:

mingw32-g++.exe -Wall -g -I"C:\Program Files (x86)\CodeBlocks\MinGW\include" -c "C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp" -o obj\Debug\main.o
C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp: In function 'int main(int, char**)':
C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp:30:29: error: 'glutInitContextVersion' was not declared in this scope

What's this mean and how can it be fixed?

Offline crinkle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: How do you fully install opengl???
« Reply #14 on: June 15, 2014, 12:06:13 am »
I also now have another query in relation to this website:

http://en.wikibooks.org/wiki/OpenGL_Programming#The_basics_arc

From an example page i found a link to the source code for the examples and decided to download it. I was sure that if ever anything was ever even remotely possible to fluke and work, it would be with fully working examples which had been set up by an expert that I could just open and run.

FYI, the download link page is here: https://gitorious.org/wikibooks-opengl/modern-tutorials/source/90bf72991caf34ea6cdbed044a9616b7bbdf2d0f:

Unfortunately (as expected), they did not work, none of them, from the simplest code to the more complex stuff, compile errors everywhere (usually starting with "___IMP___" for some reason), Here's the build log for tut01_intro\triangle.cpp:

Code
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1c): undefined reference to `_imp____glutInitWithExit@12'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3e): undefined reference to `_imp____glutCreateWindowWithExit@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x60): undefined reference to `_imp____glutCreateMenuWithExit@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xb1): undefined reference to `_imp____glewCreateShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xd5): undefined reference to `_imp____glewShaderSource'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xfe): undefined reference to `_imp____glewCompileShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x110): undefined reference to `_imp____glewGetShaderiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x16a): undefined reference to `_imp____glewCreateShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x18e): undefined reference to `_imp____glewShaderSource'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1b7): undefined reference to `_imp____glewCompileShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1c9): undefined reference to `_imp____glewGetShaderiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x223): undefined reference to `_imp____glewCreateProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x238): undefined reference to `_imp____glewAttachShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x253): undefined reference to `_imp____glewAttachShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x26e): undefined reference to `_imp____glewLinkProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x282): undefined reference to `_imp____glewGetProgramiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x2e2): undefined reference to `_imp____glewGetAttribLocation'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3d0): undefined reference to `glClearColor@16'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3df): undefined reference to `glClear@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3e7): undefined reference to `_imp____glewUseProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3fb): undefined reference to `_imp____glewEnableVertexAttribArray'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x424): undefined reference to `_imp____glewVertexAttribPointer'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x476): undefined reference to `glDrawArrays@12'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x47e): undefined reference to `_imp____glewDisableVertexAttribArray'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x492): undefined reference to `_imp__glutSwapBuffers@0'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x4c9): undefined reference to `_imp____glewDeleteProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x519): undefined reference to `_imp__glutInitContextVersion@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x52a): undefined reference to `_imp__glutInitDisplayMode@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x543): undefined reference to `_imp__glutInitWindowSize@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x55c): undefined reference to `_imp__glewInit@0'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x572): undefined reference to `_imp__glewGetErrorString@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x5b4): undefined reference to `_imp__glutDisplayFunc@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x5be): undefined reference to `_imp__glutMainLoop@0'

glut (freeglut is installed), glew is installed, GLM is installed now as well. What else needs to be installed?

For the record I have not edited the code at all. I literally just opened codeblocks, opened the .cpp file and ran it. No adjustments.

Can anyone confirm that any of the code from the above site works at all? I'm starting to think its actually not me now...

If anyone can make any of this code run, please advise what else is needed to be installed in codeblocks...