On Sat, 22 Feb 2003 22:30:23 +0200, <- Chameleon -> staggered into the
Black Sun and said:
> I tried to compile my program source (1 file only: main.cpp) with this
> gcc -B /root/SDL-1.2.5/include main.cpp
> ERROR! gcc cannot find SDL.h! (this file is in path:
Nope. SDL.h should be in /usr/include/SDL/ or /usr/include/ or
/usr/local/include/ . Are you sure you installed the library properly?
And why are you doing this as root? The rule is, "Never do anything as
root that you can do as a normal user," and compiling programs can
certainly be done as a user.
Quote:> #include "SDL.h"
> I copied this file (and sub-includes) in main.cpp path. BUT now gcc
> has found undefined symbols! Functions like: sin cos glVertex3i
> SDL_Init This means that gcc is not linking Libraries with object from
> Source Code. What I can do?
Start by finding a good introductory book on C in a Unix environment,
and pay attention to the syntax examples it gives for linking to
external libraries and finding external header files. If you want to
link the external library FOO with your program, you've entered
'#include "FOO.h" ' in your .c file, FOO.h is in /somewhere/include ,
and your library file "libFOO.a" is in /somewhere/lib , you'd do this:
gcc -o myprogram myprogram.c -I/somewhere/include -L/somewhere/lib -lFOO
-I specifies an additional path to search for headers. -L specifies an
additional path to search for libraries. -l specifies the external
libraries to link against.
-B is the *wrong* option to feed gcc according to the man page. That
option tells gcc where to find the executable, libraries, and include
files for the compiler itself. This is typically /usr/lib/gcc and will
not be different unless you've installed the compiler to a weird place
or you are rebuilding gcc itself.
Quote:> Please give me a correct gcc syntax. I use OpenGL, GLU, <math.h>,
See above. Remember "-lm -lGL -lGLU -lGLCore -lSDL" or you'll get link
errors and be confused. The OpenGL headers will probably be in
Quote:> I cannot create Makefile! I am too newbie!
If you're going to program in a Unix environment, you need to learn to
create Makefiles. A good book on C in a Unix environment will give you
a basic overview; otherwise, Google for "Makefile tutorial".
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin /
http://www.brainbench.com / "He is a rhythmic movement of the
-----------------------------/ penguins, is Tux." --MegaHAL