Undefined symbol in gcc & c++
From: Stanley Yao (yao_at_CS.Arizona.EDU)
Date: 07/22/03
- Next message: Rex Ballard: "Re: Rex Ballard you ignorant piece of ***."
- Previous message: Rex Ballard: "Re: Rex Ballard the self claimed open source advocate using Windows BUAHAHAHAHAHA"
- Next in thread: Steve Bellenot: "Re: Undefined symbol in gcc & c++"
- Reply: Steve Bellenot: "Re: Undefined symbol in gcc & c++"
- Reply: Oscar del Rio: "Re: Undefined symbol in gcc & c++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Tue, 22 Jul 2003 09:56:57 -0700
Dear All,
I built the following little C program into a library (libtt.a) with gcc:
/* Filename: tt1.c */
#include <stdio.h>
int foo() {
return 1;
}
gcc -c tt1.c
ar -rs libtt.a tt1.o
Then I wrote the following C++ program and want to link with libtt.a and
failed.
/* Filename: tt2.cc */
int foo();
int main() {
int k;
k = foo();
return 0;
}
% c++ tt2.cc -L. -ltt
Undefined first referenced
symbol in file
foo() /var/tmp//cc02ILOd.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
% c++ tt2.cc tt1.o
Undefined first referenced
symbol in file
foo() /var/tmp//ccgMpZee.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
% g++ tt2.cc libtt.a
Undefined first referenced
symbol in file
foo() /var/tmp//cc8Kx1jd.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
% gcc tt2.cc tt1.o
Undefined first referenced
symbol in file
foo() /var/tmp//ccUM2g0c.o
__gxx_personality_v0 /var/tmp//ccUM2g0c.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
Did I do something wrong? How can I get these 2 pieces (one is C, the
other is C++) linked together?
Thank you very much!
-Stan
- Next message: Rex Ballard: "Re: Rex Ballard you ignorant piece of ***."
- Previous message: Rex Ballard: "Re: Rex Ballard the self claimed open source advocate using Windows BUAHAHAHAHAHA"
- Next in thread: Steve Bellenot: "Re: Undefined symbol in gcc & c++"
- Reply: Steve Bellenot: "Re: Undefined symbol in gcc & c++"
- Reply: Oscar del Rio: "Re: Undefined symbol in gcc & c++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]