newbie gcc question...
Claudio Bley
bley@cs.uni-magdeburg.de
Mon Apr 29 18:45:00 GMT 2002
>>>>> "Michael" == Michael Kahle <geopoliticus@onebox.com> writes:
Michael> I am trying to teach myself the c language and a program
Michael> I am creating at compile time is giving me the error:
Michael> undefined reference to 'bla_bla1' undefined reference to
Michael> 'bla_bla2' undefined reference to 'bla_bla3' etc...
Michael> This is the first c program I have written that requires
Michael> me to use the #include directive in my program. I have a
Michael> file called bla_bla.h in this file i have the lines: void
Michael> bla_bla1(int); int bla_bla2(int); int bla_bla3(int); I
Michael> also have another file called tbla_bla.c that has the
Michael> directive: #include "bla_bla.h" in it.
Producing an executable program is usually a 2 step process. At first
you let the compiler generate object files, afterwards the linker
takes these files and links them together to one executable program.
So, to generate object files run
gcc -c <file.c>
on every C source file you've got.
Then, run for example:
gcc foo.o bar.o -lm
This will produce the file a.out (use -o <outfile> to name it
differently) by linking the 2 object files foo.o and bar.o together
and also linking with the math library when necessary (-lm means to
search for libm.so or libm.a).
You should have a look at "Advanced Linux Programming". It gets really
'advanced' on some subjects, but it starts out with the basics:
http://www.advancedlinuxprogramming.com/
HTH
Claudio
More information about the Gcc-help
mailing list