PDA

View Full Version : HELP: I can't get passed step1!



The_Dj
06-06-2003, 03:12 AM
Greetings.

I'm getting link errors.
I'm running cygwin, downloaded a few days ago, so it's gcc 3.2.3

Source Code: prog.C
#include <GL/glut.h>
int main(int argc, char** argv)
{
glutInit (&argc, argv) ;

return 0 ;
}

compiled with:
gcc -lglui -L/lib/w32api -o prog.exe prog.C

Result:
Temp/ccCh0KDT.o(.text+0x2c) :prog.C: undefined reference to `_glutInit@8'

I have confirmed that the string "_glutInit@8" appears in /lib/w32api/libglui.a

So why does the Linking fail??????

help

[This message has been edited by The_Dj (edited 06-06-2003).]

pantheman
06-06-2003, 03:29 AM
i would have compiled with something like
g++ prog.C -o exe -L/lib/w32api -lglui prog.exe

instead of:
gcc -lglui -L/lib/w32api -o prog.exe prog.C

it just looks like your compile fields are mixed up. learning how to use gmake by creating a Makefile may help you remember compiling rules.

hope this helps,
-rufeo

The_Dj
06-06-2003, 03:34 AM
Thanks for the reply, but:

swapping the order of the parameters has made no difference.

I normally do use a Makefile, but I didn't want to complicate the question.

Dj.

pantheman
06-06-2003, 03:36 AM
oops!
i should know my compile rules!

g++ code.C -o name.exe -L{libPath} -l{libName}

nothing should come after the library name.

The_Dj
06-06-2003, 03:37 AM
Yeah, I figured that. :-P

pantheman
06-06-2003, 03:39 AM
and now for the obvious solution:

don't link glui ! link glut!

path = {?}
name = -lglut

sorry i missed it.
-pantheman

The_Dj
06-06-2003, 03:47 AM
Linking glu32 solved that.

But now I'm getting others as I add more code.

I'll look into what extras I need for them before posting here again.

Thanks for the help.

The_Dj
06-06-2003, 03:50 AM
Yup. Working.

Odd, this, I tried linking to most libraries that seemed right, including these.

I think my final solution was changing the order of switches in my Makefile as well as choosing the right libs.

Live & learn.

pantheman
06-06-2003, 03:54 AM
glut is the lib you actually need.

if you don't have it already (not a standard lib) then search with google for it and you will probably find Nate Robbins name attached. he should have any win32 libs precompiled with a readme about how to install. i don't know if the rules will apply with cygwin, but to make things easy, put any libs where your glui lib is and use the same path. you may need to do the same with the glut's header file.