🔒 Locked
*really* basic OpenGL problem
Advertisement
Original Post
I copied the following piece of code from OpenGL Super Bible, but when I compile it, it brings up two errors!
#include
#include // Console I/O functions
#include // OpenGL functions
#include // AUX Library functions
void main(void)
{
// These are the AUX functions to set up the window
auxInitDisplayMode(AUX_SINGLE / AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("My first OpenGL Program");
// These are the OpenGL functions that do something in the window
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
// Stop and wait for a keypress
cprintf("Press any key to close the Window\n");
getch();
}
I thought I could catcht the first error- cprintf? Is that correct? When I bump off the c, the number of errors is reduced to one, but why would the author put a c in front of printf? Anyhow, the other error I can''t find. What''s wrong with this? The following libraries are include:
opengl32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
can anyone please please help me with this? If this book is going to be full of errors, I''m gonna be upset...
Programming::~Fredric(const Annoy_Ance)
How did you create the project? You are using Visual C++ I assume? You need to be sure that whatever compiler you are using knows you are trying to compile a console app. In Visual C++ this is just a matter of picking console app within the create project wizard.
cprintf and getch only make sense within the context of a console app, and your mysterious second error when cprintf is removed is probably a linking error due to the fact that the linker is looking for a WinMain and not finding one.
cprintf and getch only make sense within the context of a console app, and your mysterious second error when cprintf is removed is probably a linking error due to the fact that the linker is looking for a WinMain and not finding one.
Um, this is probably obvious, but according to your code you haven''t actually specified anything to include after the #include calls.
I have all the right ingludes, trust me.
To have make the app I went into VC++ and chose to make a Win32 Console App (the one with the window with the windows logo inside it). I included ALL the right stuff...
It''s for UNIX? What the hell? Then what book should I buy? I need a book that assumes that the person knows ONLY C++, and nothing else.
To have make the app I went into VC++ and chose to make a Win32 Console App (the one with the window with the windows logo inside it). I included ALL the right stuff...
It''s for UNIX? What the hell? Then what book should I buy? I need a book that assumes that the person knows ONLY C++, and nothing else.
The OpenGL Super Bible is in fact for OpenGL on Windows NT and Windows 95/98. (At least the book at ITKnowledge that I tipped you about.
)
If you posted the exact error messages that you compiler gives you it would be easier to help you.
If you posted the exact error messages that you compiler gives you it would be easier to help you.
This is what i get after I type in the source code and try to build it...
--------------------Configuration: SmallestPossible - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/SmallestPossible.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
SmallestPossible.exe - 2 error(s), 0 warning(s)
I hope this helps
Programming::~Fredric(const Annoy_Ance)
--------------------Configuration: SmallestPossible - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/SmallestPossible.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
SmallestPossible.exe - 2 error(s), 0 warning(s)
I hope this helps
Programming::~Fredric(const Annoy_Ance)
The AP above is right. But just to clarify things, when you started your project you chose the "Win32 Application" type, you should have chosen "Win32 Console Application".
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement