This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference error in static libraries.
- From: Niklaus <niklaus at gmail dot com>
- To: "steven woody" <narkewoody at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 29 Apr 2006 13:28:43 +0530
- Subject: Re: undefined reference error in static libraries.
- References: <ed4892840604262038j6cc8858djec9b65ff516d560f@mail.gmail.com>
On 4/27/06, steven woody <narkewoody@gmail.com> wrote:
hi, i am build a program, the structure of the source is below,
main.o
main.c
libfoo.a
foo.c
libbar.a
bar.c
and, the foo.c has a reference to function bar() which is defined in bar.c
i can successfully compile and produce libfoo.a and libbar.a. but when
compile main.o, i get an error like following:
gcc -g -O2 -o main.o main.o libfoo.a libbar.a
it should be -o a.out or something like that because main.o is overwritten.
Please paste the code
libfoo.a(libfoo_a-foo.o): in function 'foo':
foo.c: undefined reference to 'bar'
what's the cause and how do i do? thanks.
--
woody