Sign in to follow this  
pex22

hiding console and including opengl libraries

Recommended Posts

for some reason, 2 days ago i could hide the console by calling:
#pragma comment(linker,"/entry:\"mainCRTStartup\" /subsystem:\"windows\"")
now i cant hide the console. my another problem, is that since i decided to leave GLUT i wrote:
#include <GL/gl.h>
#include <GL/glu.h>
and i get these errors when using the engine:
#include "stdafx.h"
#include "c:\\pex\\engine\\stdafx.h"
#pragma comment(lib,"c:\\pex\\engine\\release\\tribox.lib")


--------------------Configuration: console - Win32 Release--------------------
Compiling...
console.cpp
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1502) : error C2143: syntax error : missing ')' before '}'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1502) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1502) : error C2143: syntax error : missing ';' before ','
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1502) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1522) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1522) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/gl.h(1522) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/glu.h(25) : error C2143: syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\GL/glu.h(25) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.

console.exe - 9 error(s), 0 warning(s)

what to do with both problems? by the way, i was wondered..will my console hiding line work on other compilers than vc6? thanks, pex.

Share this post


Link to post
Share on other sites
ok, first of all, Glut is more for educative purpose.
The gl.h and glu.h are the best way to make game
And probably you forgot to include those lib to the projet :

OpenGL32.lib GLu32.lib

Share this post


Link to post
Share on other sites
this is a part of my engine's stdafx.h:
#define WIN32_LEAN_AND_MEAN		/* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
#pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
#pragma comment (lib, "glu32.lib") /* link with OpenGL Utility lib */

#pragma warning (disable:4244) /* Disable bogus conversion warnings. */
#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */

#include <GL/gl.h>
#include <GL/glu.h>





.lib errors would be linking errors, not compiling errors.
petewood, so yes i included windows.h
edit: i had no errors when i used glut (i included glut.h only when i used)
i dont know if it is useful, but this is the beginning of glut.h:
#if defined(_WIN32)

/* GLUT 3.7 now tries to avoid including <windows.h>
to avoid name space pollution, but Win32's <GL/gl.h>
needs APIENTRY and WINGDIAPI defined properly. */

# if 0
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# else
/* XXX This is from Win32's <windef.h> */
# ifndef APIENTRY
# define GLUT_APIENTRY_DEFINED
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
/* XXX This is from Win32's <winnt.h> */
# ifndef CALLBACK
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# endif
/* XXX This is from Win32's <wingdi.h> and <winnt.h> */
# ifndef WINGDIAPI
# define GLUT_WINGDIAPI_DEFINED
# define WINGDIAPI __declspec(dllimport)
# endif
/* XXX This is from Win32's <ctype.h> */
# ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
# define _WCHAR_T_DEFINED
# endif
# endif

#pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
#pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
#pragma comment (lib, "glu32.lib") /* link with OpenGL Utility lib */
#pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */

#pragma warning (disable:4244) /* Disable bogus conversion warnings. */
#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */

#endif

#include <GL/gl.h>
#include <GL/glu.h>

i copied-pasted this code to replace my current code, but i got the same errors and even more errors because i use thingys that defined in windows.h

Share this post


Link to post
Share on other sites
Quote:
Original post by pex22
#pragma comment(linker,"/entry:\"mainCRTStartup\" /subsystem:\"windows\"")



The proper way to do this is to specify that you want a GUI application (not a console app) when you create the project. I'm not sure how/if you can change it afterwards in VS6...
Same goes for libraries. Go into the project settings and add them in the Link tab.

In general you can NOT rely on #pragmas to work in all compilers

Share this post


Link to post
Share on other sites
oh, nevermind about the opengl libraries.
seems like the problem was because i included stdafx.h twice (of different projects). [smile]
but i still try to hide my console.
the hiding #pragma works without the engine, but when i use the function inside the engine the console is shown.
anyone?

edit: oh almost forgot, when i try to hide the console using the engine i get 3 warnings:
Linking...
LINK : warning LNK4089: all references to "GDI32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "OPENGL32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "USER32.dll" discarded by /OPT:REF

console.exe - 0 error(s), 3 warning(s)

what does it mean?
(it doesn't appear when i create a window using the engine)

thanks, pex.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this