Hello
I'm new in C, And I want to compile program which use extern function.
How to do it because I always got error.
Undefined first referenced
symbol in file
greet /tmp/cchAXHfp.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
first I did "gcc -G -o libgreet.so greet.c" and it is ok.
Later I tried:
gcc -G -lgreet mix.c
gcc -L/local/data02/app/repapp/test/gp
-I/local/data02/app/repapp/test/gp mix.c
gcc -L/local/data02/app/repapp/test/gp mix.c
And always I got error.
Thx
Robert
bash-2.05$ cat greet.h
char *greet();
bash-2.05$ cat greet.c
#include "greet.h"
char *greet() {
return ((char *) "Hello!");
}
bash-2.05$ cat mix.c
#include <stdio.h>
extern char *greet();
int main() {
char *greeting = greet();
printf ("aa\n");
return (0);
}