OpenGL and c++ error...

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 986 Views - Last Post: 08 February 2018 - 12:45 PM Rate Topic: -----

#1 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

OpenGL and c++ error...

Posted 27 January 2018 - 10:14 AM

Hello so I am trying to open a window and I used the code from:

http://www.opengl-tu...pening-a-window

and I get 18 errors some from Makefile.win and GLwindow.o (GLwindow.cpp's <My added file> other file that dev c++ adds.)

And I also get a collect2.exe error...

Please help

Errors:

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0xe): undefined reference to `glfwInit'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x57): undefined
reference to `glfwWindowHint'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x66): undefined reference to `glfwWindowHint'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x75): undefined reference to `glfwWindowHint'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x84): undefined reference to `glfwWindowHint'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x93): undefined reference to `glfwWindowHint'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0xb8): undefined reference to `glfwCreateWindow'


C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0xef): undefined reference to `glfwTerminate'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x105): undefined reference to `glfwMakeContextCurrent'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x10c): undefined
reference to `__imp_glewExperimental'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x116): undefined reference to `__imp_glewInit'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x166): undefined reference to `glfwSetInputMode'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x172): undefined reference to `glfwSwapBuffers'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x177): undefined reference to `glfwPollEvents'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x188): undefined reference to `glfwGetKey'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\GLwindow.o GLwindow.cpp:(.text+0x199): undefined reference to `glfwWindowShouldClose'

C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\collect2.exe [Error] ld returned 1 exit status
25 C:\Users\flami\Desktop\KEEP\Codes\CPP\GLWindow\Makefile.win recipe for target

'GLwindow.exe' failed

Is This A Good Question/Topic? 0
  • +

Replies To: OpenGL and c++ error...

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1460
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: OpenGL and c++ error...

Posted 27 January 2018 - 10:39 AM

The errors are indicating you have not linked to the GLFW library

http://www.glfw.org/...test/index.html

If you dont know how to do that then you would have to tell us your compiler IDE combo.

or just the compiler if compiling from the command line.
Was This Post Helpful? 0
  • +
  • -

#3 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 10:58 AM

View Postsnoopy11, on 27 January 2018 - 10:39 AM, said:

The errors are indicating you have not linked to the GLFW library

http://www.glfw.org/...test/index.html

If you dont know how to do that then you would have to tell us your compiler IDE combo.

or just the compiler if compiling from the command line.



Yeah I have no idea how to link to the GLFW library... I am not sure what compiler IDE combo it is and I am also not sure if it compiles from the command line... possibly not (I am using Dev C++)
Was This Post Helpful? 0
  • +
  • -

#4 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:27 AM

View PostFlamingBurrito15, on 27 January 2018 - 10:58 AM, said:

View Postsnoopy11, on 27 January 2018 - 10:39 AM, said:

The errors are indicating you have not linked to the GLFW library

http://www.glfw.org/...test/index.html

If you dont know how to do that then you would have to tell us your compiler IDE combo.

or just the compiler if compiling from the command line.



Yeah I have no idea how to link to the GLFW library... I am not sure what compiler IDE combo it is and I am also not sure if it compiles from the command line... possibly not (I am using Dev C++)


OK never mind I fixed it but now it won't run because its in 16-Bit not 64-Bit... any ideas on how to fix this?

EDIT: I also included glm.h because it seemed to stop the errors then it is telling me there is an error with #pragma once...

This post has been edited by FlamingBurrito15: 27 January 2018 - 11:34 AM

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 14038
  • View blog
  • Posts: 56,177
  • Joined: 12-June 08

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:33 AM

Please copy/paste any error messages here.
Was This Post Helpful? 0
  • +
  • -

#6 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:38 AM

View Postmodi123_1, on 27 January 2018 - 11:33 AM, said:

Please copy/paste any error messages here.


I would but I can't get it to tell me that error because suddenly
#pragma once
is now messing everything up...
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 14038
  • View blog
  • Posts: 56,177
  • Joined: 12-June 08

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:40 AM

Please elaborate on "is now messing everything up". Remember folk are not there sitting and looking over your shoulder. Being as verbose, and complete, in your explanation is crucial to others being able to help you.
Was This Post Helpful? 0
  • +
  • -

#8 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:42 AM

View Postmodi123_1, on 27 January 2018 - 11:40 AM, said:

Please elaborate on "is now messing everything up". Remember folk are not there sitting and looking over your shoulder. Being as verbose, and complete, in your explanation is crucial to others being able to help you.


it's just giving me an error that's all
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 14038
  • View blog
  • Posts: 56,177
  • Joined: 12-June 08

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:52 AM

... So it is giving you an error?
Was This Post Helpful? 0
  • +
  • -

#10 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1460
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: OpenGL and c++ error...

Posted 27 January 2018 - 11:54 AM

You would have to replace all the #pragma once comments

with #ifndef

#endif blocks

https://www.cprogram...sor/ifndef.html

This is because #pragma comments are exclusive to the Microsoft C++ compiler cl.exe

If you are using dev C++ and you really shouldn't be the compller you are using is a MinGW version.

You really need to learn the basics first before tackling advanced projects like OpenGL.

In the DEV C++ IDE

1) click on the Projects ->"Project Options"->"Parameters"

2) under "Linker", where it says: "Add Library or Object",
click that button,

Your glfw library will be called libglfw.a


However my personal feeling is you are not ready for this type of project yet.
Was This Post Helpful? 0
  • +
  • -

#11 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 12:00 PM

View Postmodi123_1, on 27 January 2018 - 11:52 AM, said:

... So it is giving you an error?


Yes... all it says in the error window is

Quote

#pragma once in main file

which glm.hpp is not my main file...

View Postsnoopy11, on 27 January 2018 - 11:54 AM, said:

You would have to replace all the #pragma once comments

with #ifndef

#endif blocks

https://www.cprogram...sor/ifndef.html

This is because #pragma comments are exclusive to the Microsoft C++ compiler cl.exe

If you are using dev C++ and you really shouldn't be the compller you are using is a MinGW version.

You really need to learn the basics first before tackling advanced projects like OpenGL.

In the DEV C++ IDE

1) click on the Projects ->"Project Options"->"Parameters"

2) under "Linker", where it says: "Add Library or Object",
click that button,

Your glfw library will be called libglfw.a


However my personal feeling is you are not ready for this type of project yet.


Yeah I know the where to link it but I did not really know what file to link it with... I with try that file
Was This Post Helpful? 0
  • +
  • -

#12 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1460
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: OpenGL and c++ error...

Posted 27 January 2018 - 12:09 PM

If your headers contain #pragma comments then you might have the VS version of the library instead of the MinGW version.

This post has been edited by snoopy11: 27 January 2018 - 12:10 PM
Reason for edit:: typo

Was This Post Helpful? 0
  • +
  • -

#13 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 12:12 PM

View Postsnoopy11, on 27 January 2018 - 12:09 PM, said:

If your headers contain #pragma comments then you might have the VS version of the library instead of the MinGW version.


Yeah I am downloading the MinGW versions now so hopefully it should work

This post has been edited by FlamingBurrito15: 27 January 2018 - 12:14 PM

Was This Post Helpful? 0
  • +
  • -

#14 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1460
  • View blog
  • Posts: 4,726
  • Joined: 20-March 10

Re: OpenGL and c++ error...

Posted 27 January 2018 - 12:14 PM

Yeah... you may have some difficulties.
Was This Post Helpful? 0
  • +
  • -

#15 FlamingBurrito15  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 71
  • Joined: 13-December 17

Re: OpenGL and c++ error...

Posted 27 January 2018 - 12:15 PM

View Postsnoopy11, on 27 January 2018 - 12:14 PM, said:

Yeah... you may have some difficulties.


Difficulties with what?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2