PDA

View Full Version : Includes



Sidney
05-12-2015, 12:14 PM
Running OpenGL under Windows 7 pro and Visual Studio 6. I have included the following libraries in my "C" program:

<Windows.h>
<gl\gl.h>
<gl\glu.h>
<gl\glaux.h>
<Stdio.h>
<math.h>
I have run this program before with no problems. However, now I try to run and get Link errors:
LNK2001 missing ext symbol _glyPerspective@32
_Imp_glLoadIdentity@0
_Imp_glMatrixMode@4
and many more, total 256 unresolved external variables, not sure what is wrong. Do I need more include files or?

Sid Kraft

hidefromkgb
05-12-2015, 12:23 PM
glyPerspective
This is definitely a typo. The correct function is called gluPerspective (https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml).
WRT other functions, your project seems to be lacking opengl32.lib and glu32.lib in Project → Link → Object/Library modules.

Sidney
05-12-2015, 06:10 PM
Running opengl with win7 pro, compiled an opengl program, tried to build and it gives me unresolved external reference "_main". The sample program was written by opengl so I would think it would "build" and "execute", not sure why I am getting "main" as an unresolved external. I usually use Fortran, not "c++" so not familiar with the missing "main", any ideas? Sid Kraft

Alfonse Reinheart
05-12-2015, 07:31 PM
Perhaps you should invest some time in programming in C++ without OpenGL, before pushing forward with OpenGL. Alternatively, you could find an OpenGL binding for Fortran. Though most such bindings are very out of date.

GClements
05-12-2015, 08:30 PM
Running OpenGL under Windows 7 pro and Visual Studio 6. I have included the following libraries in my "C" program:
<Windows.h>
<gl\gl.h>
<gl\glu.h>
<gl\glaux.h>
<Stdio.h>
<math.h>


1. Those aren't libraries, they're headers. You still need to link against the appropriate libraries.

2. The "aux" library is ancient history. Even if you can find a version which works on modern systems, don't expect to find anyone who still remembers anything about it in the event that you need to ask for help. Convert the code to use GLUT (or GLFW, or something else reasonably modern).

GClements
05-12-2015, 08:36 PM
While I agree with the sentiment of Alfonse' response, the most common cause of that specific issue is telling the IDE that you're building a "GUI application" (which expects a WinMain() function) rather than a "console application" (which expects a main() function).

Note that console applications can still use GUI features; the only real difference is that console applications use the standard main() entry point and have stdin/stdout/stderr set up, while GUI applications use the Windows-specific WinMain() entry point and don't have the standard streams.

Sidney
05-13-2015, 05:40 AM
OK People, so I need more experience with C++, will do, but how do I get the "main" attribute attached to my program at this time so I can execute. Sid Kraft

Alfonse Reinheart
05-13-2015, 06:23 AM
Here's one idea: if you're going to ask a introductory general programming question on an OpenGL forum, you could at least stop making new threads for dealing with the same issue. You could also use Google to learn something about C++.

"main" is not an "attribute"; it's the name of a function. As the name suggested, it's the "main" function in C++. It's what starts a program's execution, and exiting the "main" function ends the program's execution.

Sidney
05-13-2015, 06:09 PM
Sorry about the confusion on different threads, I am a first time user to this forum, don't know how to use it yet. Sid Kraft

Sidney
05-15-2015, 06:39 PM
Note: That I have the identical code on my laptop computer and it runs fine without a "main" program, I ran that same thing on my desktop computer with all of the settings for the C++ compiler and the linker the same and the system gets an error that the unresolved variable "_main" is missing!! not sure what the problem is, any help would be appreciated. Both computers running Win 7 Pro! Sid Kraft