PDA

View Full Version : Help!



Procyon
07-31-2002, 01:28 PM
I'm trying to get started in opengl, I tried compiling a simple program, but I get
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/gl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Dunno whats going on. Help?

Latrans
07-31-2002, 01:33 PM
Some people should never be allowed near a compiler.

07-31-2002, 01:44 PM
Try doing a search. This topic has been covered many times before.

Procyon
07-31-2002, 06:43 PM
Latrans,
Your response was uncalled for. Or maybe you were born knowing these things.

Myotis,
Thanks for the suggestion, but I am not sure what should I use to search for this problem. It is very confusing for me.

chowe6685
07-31-2002, 07:08 PM
you created a windows appication, and created at void main() function, but the compiler expects a int WinMain(...), try creating a console application and moving your code there or replace void main() with int WinMain(...), though you would have to look up the parameters

07-31-2002, 08:39 PM
I agree with Latrans.

07-31-2002, 09:23 PM
The Parameter is void
so go:

void main(void)
{
}

jamac
08-01-2002, 12:32 AM
Originally posted by Latrans:
Some people should never be allowed near a compiler.

I thoroughly disagree with Latrans. I've been working with openGL for about two years now and with C++ alot longer. You do not wake up with this information one moring. It is blood and tears at the start then it gets much easier.

This sort of elitist attitude pisses me off. Latrans, you are a bit of a tube!

Procyon
08-01-2002, 05:18 AM
Chowe,
Thanks for your help. But now I have a different problem. I get the error

LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

Latrans
08-01-2002, 05:45 AM
I agree that it takes some time to learn to program. And even longer to learn to program well. But so many questions here are questions on how to program, not questions on OpenGL. If only people would learn to program before they learn to program with OpenGL, their life would be so much simpler. People can hurt themselves trying to run before they can walk.

Procyon
08-01-2002, 06:00 AM
Latrans,
I took a full semester of C++ in high school, so I do know how to program. I don't think this is a normal programming error.

drummerboy_2002
08-01-2002, 08:05 AM
Some people in this thread remind me of that SNL scetch:
"Nick Burns, the company's computer guy"

08-01-2002, 08:17 AM
replace "int main() or void main() ... "

with
"
int WINAPI
WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
"

then add
"
int main()
{
return WinMain(GetModuleHnadle(),0,NULL,1);
}

"

nickels
08-01-2002, 08:36 AM
Procyon,

1) Ignore the jerkoffs

2) Are you using GLUT or AUX? If you are, then you need to tell the compiler to create a console app.

3) If you are not using GLUT or AUX, you need to learn how to basic windows programming (creating a WinMain, and windows.) This can take a considerable amount of time, so I would suggest trying GLUT or AUX to start.

4) Good day

Procyon
08-01-2002, 08:52 AM
Thanks. I figured out my first problem. It was very stupid. I was using Main instead of main. I didn't think that it would make a difference, but it did.

Now I have another problem, though. I have a struct like this:
struct Bug
{
float posX, posY, posZ;
};

And a function like this:

Bug* CreateRandomBugs(int bugCount)
{
Bug bugs[bugCount];

for (int c=0;c<bugCount;c++)
{
bugs[c].posX = rand() % 100;
bugs[c].posY = rand() % 100;
bugs[c].posZ = rand() % 100;
}

return bugs;
}

When I try to compile, I get these errors
Compiling...
firstGL.cpp
f:\temp\firstGL\firstGL.cpp(61) : error C2057: expected constant expression
f:\temp\firstGL\firstGL.cpp(61) : error C2466: cannot allocate an array of constant size 0
f:\temp\firstGL\firstGL.cpp(61) : error C2133: 'bugs' : unknown size
f:\temp\firstGL\firstGL.cpp(65) : error C2065: 'rand' : undeclared identifier
f:\temp\firstGL\firstGL.cpp(70) : warning C4172: returning address of local variable or temporary
Error executing cl.exe.

firstGL.exe - 4 error(s), 1 warning(s)

Please help me, I am about to pull out all my hair!

08-01-2002, 09:38 AM
It might be helpful for you to get a good book on C/C++ before attempting to do much OpenGL. If you are struggling with the mechanics of the language at the same time you're struggling with the mechanics of OpenGL, you'll just end up giving yourself major headaches.

Latrans
08-01-2002, 10:01 AM
I guess your one semester of C++ didn't teach you much about how memory is used, eh?

chowe6685
08-01-2002, 10:15 AM
you will need to use either new or malloc() to allocate memory dynamically, if you have no idea what I am talking about I recommend brushing up on your c++ before attempting to use OpenGL

Jeeeez
08-01-2002, 10:17 AM
This line

Bug bugs[bugCount];

is wrong.

You cannot create a static array with anything other than a constant or a define.

Try dynamically allocating...
ie
Bug* bugs;
bugs=new Bug[bugcount];


but be sure to delete the array after you use it.

delete []bugs;

As myotis said, you should have a good c or c++ book nearby, or check out some c websites. Learning both c and opengl at the same time could be a bit confusing.

http://www.opengl.org/discussion_boards/ubb/smile.gif
Jeremy

Procyon
08-01-2002, 10:37 AM
Thanks. My function is now this:

Bug* CreateRandomBugs(int bugCount)
{
Bug* bugs = new Bug[bugCount];

for (int c=0;c<bugCount;c++)
{
bugs[c].posX = rand() % 100;
bugs[c].posY = rand() % 100;
bugs[c].posZ = rand() % 100;
}

delete []bugs;

return bugs;
}


I still get the error:
f:\temp\firstGL\firstGL.cpp(65) : error C2065: 'rand' : undeclared identifier

About books. I have a book, but I am too lazy to read it.

Latrans
08-01-2002, 11:14 AM
Racoons should definitely never be allowed near a compiler. Dirty little animals, and they carry rabies.

08-01-2002, 12:13 PM
Originally posted by Procyon:
I still get the error:
f:\temp\firstGL\firstGL.cpp(65) : error C2065: 'rand' : undeclared identifier

About books. I have a book, but I am too lazy to read it.


Well U better start reading it. As these guys are saying you need to learn Cpp whole again.
by the way include <stdlib.h> and ............

08-01-2002, 01:21 PM
Funny, one of the first things I learned back in my first programming class was that C was case sensitive. So clearly, main!=Main.

Oh yeah, != means "not equal to." Just for future reference.

john
08-01-2002, 02:11 PM
Bug* CreateRandomBugs(int bugCount)
{
Bug* bugs = new Bug[bugCount];

for (int c=0;c<bugCount;c++) {
bugs[c].posX = rand() % 100;
bugs[c].posY = rand() % 100;
bugs[c].posZ = rand() % 100;
}

delete [] bugs; // <gah>

return bugs;
}

It's good that you listened to Jeeez about deleting arrays when you're finished with them, but you probbaly don't want to delete the array before you return it to the calling function.

I've never seen a racoon near a compiler before. Actually, I've never seen a racoon.

cheers
John

Jan
08-01-2002, 02:19 PM
Usually i donīt care if a beginner has a stupid question, but:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRR RRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHH HHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

lsdi
08-01-2002, 07:52 PM
Almost all replys above are wrong.

To compile a C program you need a C Project same for WIN32 projects.

:PPPP

08-01-2002, 08:36 PM
Here's something I find a bit interesting. Three people posting to this thread have names related to taxonomic classification of mammals. I know this because I got a Zoology degree before I went into Computer Science.

Procyon - Genus Procyon of the family Procyonidae. One member of which is the Procyon lotor, commonly referred to as a racoon.

Latrans - Canis latrans. Commonly referred to as a coyote.

Myotis - Genus of bats. One of which is the Myotis lucifigus, or little brown bat.

Anyway... don't have anything else to contribute. Just found that interesting. http://www.opengl.org/discussion_boards/ubb/smile.gif

08-02-2002, 02:45 AM
Thanks everyone, it has been one of the most funny thread that i have never rode in a forum.

Now, seriously... all that is a joke and all you are agree, isn it?

08-02-2002, 05:57 AM
my favourite part is that about taxonomic classification..

Latrans
08-02-2002, 06:08 AM
Latrans,
you be quiet. I am not even listening to you anymore.

Procyon
08-02-2002, 06:09 AM
Oops. I mean...

Latrans,
You be quiet. I am not even listening to you anymore.

08-02-2002, 06:13 AM
I get so confused about who I am lately...