Archived

This topic is now archived and is closed to further replies.

Presenting the Newbiest Newbie from Newbity-doobie land!

This topic is 5280 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone. I think i''m going to be hanging around these boards more often. This is my first post though. Here is the scoop. I am 17 now. I have been doing dos programming my whole life. particularly quickbasic and asm programming, but i dabbled in c(DJGPP). I recently waded into windows with some VB6 and BlitzBasic/DarkBasic (I will be suprised if people here even knows the blasphemy that is DarkBasic) ANyways, I really want to use c++ and OpenGL because I am so tired of being limited. So: I downloaded DevC++, OpenGL2, and GLUT and I am very disappointed. So far I have hardly been able to complile ANYTHING. None of the Glut or ogl examples will work. Even the "Hello-world" program that comes with DevC++ wouldnt compile! I don''t have the money for VC++ and im a complete dumbass. What am i going to do!?!?!??!! -= Twisted Matrix =-

Share this post


Link to post
Share on other sites
here is a nice c++ WIN32 and OpenGL tutorial site:

GameTutorials.com

Use it. The people there are really helpful

Jeff D

EDIT: I don't know much about DevC++ but I do know that you need to include stdio.h and add system("PAUSE"); before return 0;
at the end of your main function hope that helped you



[edited by - Jeff D on October 22, 2002 4:43:04 PM]

Share this post


Link to post
Share on other sites
quote:

Even the "Hello-world" program that comes with DevC++ wouldnt compile!



It''s probably because of the settings of the compiler you use. Sorry, but I don''t use DevC++, can''t help any further.


My compiler generates one error message: "does not compile."

Share this post


Link to post
Share on other sites

#include <stdio.h>
#include <stdlib.h>

int main
{
printf("Hello World\n");
printf("This is my first program.");

system("PAUSE");
return 0;
}

/*C version of Hello World above*/

#include <iostream>
#include <stdlib.h>

using namespace std;

int main
{
cout << "Hello World" << endl;
cout << "This is my first program.";

system("PAUSE");
return 0;
}

//C++ version of Hello World above



These two programs should work with Dev-C++ or any C/C++ compiler. Also for OpenGL, you need to go the Bloodshed.net site and look for the section on how to setup the library for GL.

Any question feel free to ask

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hello,

Need more info. When you say it doesn''t compile what do you mean? I had a problem with dev-c++ where the compile would just hang and do nothing, never new why just downloaded the most recent version and it worked.

Share this post


Link to post
Share on other sites
They say DevC++ and MinGW (They come in a package. IDE and c++ compiler), are supposed to be the next best *free* thing to VC++.

Thanks Jeff. No that dosent really help. I seem to be having problems with linking. here are a few average errors for ya...

Generated by the OpenGL demo, fullscreen.c
-----------------------------------------------------------------
c:\windows\TEMP\ccR11xfb.o(.text+0x334):fullsc~1.c: undefined reference to `glClear@4''
c:\windows\TEMP\ccR11xfb.o(.text+0x395):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x3b6):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x426):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x43d):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x46b):fullsc~1.c: undefined reference to `glRecti@16''
c:\windows\TEMP\ccR11xfb.o(.text+0x536):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x55e):fullsc~1.c: undefined reference to `glFlush@0''
c:\windows\TEMP\ccR11xfb.o(.text+0x56c):fullsc~1.c: undefined reference to `SwapBuffers@4''
c:\windows\TEMP\ccR11xfb.o(.text+0xa87):fullsc~1.c: undefined reference to `ChoosePixelFormat@8''
c:\windows\TEMP\ccR11xfb.o(.text+0xac0):fullsc~1.c: undefined reference to `SetPixelFormat@12''
c:\windows\TEMP\ccR11xfb.o(.text+0xaf3):fullsc~1.c: undefined reference to `DescribePixelFormat@16''
c:\windows\TEMP\ccR11xfb.o(.text+0xb80):fullsc~1.c: undefined reference to `wglCreateContext@4''
c:\windows\TEMP\ccR11xfb.o(.text+0xb9a):fullsc~1.c: undefined reference to `wglMakeCurrent@8''
c:\windows\TEMP\ccR11xfb.o(.text+0xcd8):fullsc~1.c: undefined reference to `wglMakeCurrent@8''
c:\windows\TEMP\ccR11xfb.o(.text+0xcfc):fullsc~1.c: undefined reference to `wglDeleteContext@4''
-----------------------------------------------------------------

-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
quote:
Original post by TwistedMatrix
Generated by the OpenGL demo, fullscreen.c
-----------------------------------------------------------------
c:\windows\TEMP\ccR11xfb.o(.text+0x334):fullsc~1.c: undefined reference to `glClear@4''
c:\windows\TEMP\ccR11xfb.o(.text+0x395):fullsc~1.c: undefined reference to `glColor3f@12''
c:\windows\TEMP\ccR11xfb.o(.text+0x3b6):fullsc~1.c: undefined reference to `glColor3f@12''
...
-----------------------------------------------------------------


Looks like an #include problem for me...



My compiler generates one error message: "does not compile."

Share this post


Link to post
Share on other sites
Granted I have know Idea what Im doing. but "fullscreen.c" has 3 include lines.

#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>

and in glut.h, some libraries appear to already be linked.

/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
in your compile preprocessor options. */
# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
# ifdef GLUT_USE_SGI_OPENGL
# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */
# else
# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
# endif
# endif


anyways, how am I supposed to know what files to link to a given program I am running. I mean, All the error I am geting is "undefined referance to blah();" Mabey If i knew every all of the functions in every LIB I could pipoint which file I am not linking or whatever.

I have no idea...

-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try including the following libraries

opengl32.lib glu32.lib glut.lib

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
When you create a new project are you using the OpenGL template?

Share this post


Link to post
Share on other sites
hmm... the following 2 lines dont seem to be linking at all

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

but the good news is, after adding -lopengl32 -lglu32, It worked. kinda. I had to REM a bunch of undefined stuff in the program. I have no idea what these are

ENUM_CURRENT_SETTINGS
CDS_FULLSCREEN

but thay are not defined anywhere... as a result the screen mode isnt set, a black 800x600 box appears in the top left of my 1024x768 desktop.

-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
Using glut in Dev-C++ isn't too hard.


          
#define GLUT_NO_LIB_PRAGMA

#define GLUT_NO_WARNING_DISABLE

#include <gl/glut.h>

#include <gl/glu.h> // Optional, but generally a good idea.



. . .


Linker Options: -lopengl32 -lglu32 -lglut32

You shouldn't need any windows stuff if you are using glut, that defeats much of the reason for using glut, i.e., portability.

[edited by - smart_idiot on October 22, 2002 6:56:32 PM]

Share this post


Link to post
Share on other sites
using Dev-C++ (and minGW) I compiled a fairly short GLUT test demo. notice in the command line that I have included all of the libs you mentioned. I have changed none of the source either...

/* Copyright (c) Mark J. Kilgard, 1994. */

/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */

#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>

char *fake_argv[] =
{
"program",
"-display",
":0",
"-geometry",
"500x400-34-23",
"-indirect",
"-iconic",
NULL};

int fake_argc = sizeof(fake_argv) / sizeof(char *) - 1;

int
main(int argc, char **argv)
{
char *altdisplay;
int screen_width, screen_height;
int got;

altdisplay = getenv("GLUT_TEST_ALT_DISPLAY");
if (altdisplay) {
fake_argv[2] = altdisplay;
}
glutInit(&fake_argc, fake_argv);
if (fake_argc != 1) {
printf("FAIL: argument processing\n");
exit(1);
}
if ((got = glutGet(GLUT_INIT_WINDOW_WIDTH)) != 500) {
printf("FAIL: width wrong, got %d, not 500\n", got);
exit(1);
}
if ((got = glutGet(GLUT_INIT_WINDOW_HEIGHT)) != 400) {
printf("FAIL: width height, got %d, not 400\n", got);
exit(1);
}
screen_width = glutGet(GLUT_SCREEN_WIDTH);
screen_height = glutGet(GLUT_SCREEN_HEIGHT);
if ((got = glutGet(GLUT_INIT_WINDOW_X)) != (screen_width - 500 - 34)) {
printf("FAIL: width x, got %d, not %d\n", got, screen_width - 500 - 34);
exit(1);
}
if ((got = glutGet(GLUT_INIT_WINDOW_Y)) != (screen_height - 400 - 23)) {
printf("FAIL: width y, got %d, not %d\n", got, screen_height - 400 - 23);
exit(1);
}
if (glutGet(GLUT_INIT_DISPLAY_MODE) !=
(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH)) {
printf("FAIL: width wrong\n");
exit(1);
}
glutInitWindowPosition(10, 10);
glutInitWindowSize(200, 200);
glutInitDisplayMode(
GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
if (glutGet(GLUT_INIT_WINDOW_WIDTH) != 200) {
printf("FAIL: width wrong\n");
exit(1);
}
if (glutGet(GLUT_INIT_WINDOW_HEIGHT) != 200) {
printf("FAIL: width wrong\n");
exit(1);
}
if (glutGet(GLUT_INIT_WINDOW_X) != 10) {
printf("FAIL: width wrong\n");
exit(1);
}
if (glutGet(GLUT_INIT_WINDOW_Y) != 10) {
printf("FAIL: width wrong\n");
exit(1);
}
if (glutGet(GLUT_INIT_DISPLAY_MODE) !=
(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL)) {
printf("FAIL: width wrong\n");
exit(1);
}
printf("PASS: test1\n");
return 0; /* ANSI C requires main to return int. */
}



C:\DEV-C_~1\BIN\g++ "c:\windows\desktop\temp\triangle\test1.o" -o c:\windows\desktop\temp\triangle\Projec~1.exe -lopengl32 -lglu32 -lglut32 C:\WINDOWS\DESKTOP\TEMP\TRIANGLE\RSRC.o -s -mwindows -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G__~1 -IC:\DEV-C_~1\INCLUDE\ -LC:\DEV-C_~1\LIB\ -BC:\DEV-C_~1\BIN\


c:\windows\desktop\temp\triangle\test1.o(.text+0x17):test1.c: undefined reference to `__glutInitWithExit''
c:\windows\desktop\temp\triangle\test1.o(.text+0x37):test1.c: undefined reference to `__glutCreateWindowWithExit''
c:\windows\desktop\temp\triangle\test1.o(.text+0x5f):test1.c: undefined reference to `__glutCreateMenuWithExit''
c:\windows\desktop\temp\triangle\test1.o(.text+0x259):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x299):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x2d9):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x2ee):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x303):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x34f):test1.c: more undefined references to `glutGet'' follow
c:\windows\desktop\temp\triangle\test1.o(.text+0x3ce):test1.c: undefined reference to `glutInitWindowPosition''
c:\windows\desktop\temp\triangle\test1.o(.text+0x3e3):test1.c: undefined reference to `glutInitWindowSize''
c:\windows\desktop\temp\triangle\test1.o(.text+0x3f0):test1.c: undefined reference to `glutInitDisplayMode''
c:\windows\desktop\temp\triangle\test1.o(.text+0x400):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x439):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x46f):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x4a9):test1.c: undefined reference to `glutGet''
c:\windows\desktop\temp\triangle\test1.o(.text+0x4dd):test1.c: undefined reference to `glutGet''


-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
9. How can i use the OpenGL library and others ?

All the libraries that comes with Mingw reside in the Lib directory. They are all named in the following way: lib*.a
To link a library with your project, just add in Project options, Further option files :
-lopengl32
This is for including the libopengl32.a library. To add any other library, just follow the same syntax:
Type -l (L in lowercase) plus the base name of the library (filename without "lib" and the ".a" extension).



This is out of Bloodshed.net. do what this says and #include the libraries again. It should work!

Hope this helps.

Share this post


Link to post
Share on other sites
Look man, thats exacly what I am doing

C:\DEV-C_~1\BIN\g++ "c:\windows\desktop\temp\triangle\test1.o" -o c:\windows\desktop\temp\triangle\Projec~1.exe -lopengl32 -lglu32 -lglut32 C:\WINDOWS\DESKTOP\TEMP\TRIANGLE\RSRC.o -s -mwindows -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G__~1 -IC:\DEV-C_~1\INCLUDE\ -LC:\DEV-C_~1\LIB\ -BC:\DEV-C_~1\BIN\




-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
wow. your ide colors are very cool. very unix. Probly hurts the hell out of your eyes after a while though.

HOORAY HOORAY I finally figured out the problem. Thank you everyone for trying to help me so much (Even though you really were not that helpfull unfortunatly ).

The reason I couldnt get anything to link was because:
either a file was corrupt or missing. Isnt it rediculous that the only error I could get was "undefined referance" I have been a BASIC type DOS programmer for a long time and I am used to very different kinds of errors. You guys were great for helping me out though. thanks.

Now I can get down to learning all these wonderfull new enviroments! (If there is one thing I learned from DJGPP/Alegro. Its that, the hardest part is installing the software and compileing all the libs for the first time. After that, learning a new programming language is a walk in the park)

-= Twisted Matrix =-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Twisted matrix, I have also programmed in ASM and quickbasic. My first IDE was BASIC in MS-DOS 2.11 - very old. Now I use a Pentium class CPU and a monitor that supports 32-bit colors. I began to program in the 320x200x256 graphics mode in QB, but it was too slow, so I began to look for other languages and libraries. Currently, I use C++ and DirectX.

Share this post


Link to post
Share on other sites