gcc Linking problem ?
Alireza Haghdoost
haghdoost@gmail.com
Sun Apr 17 07:30:00 GMT 2011
Hello
Would you please let me know why I have this error when I try to link
my object files:
$ gcc -c stack.cpp -o stack.o
$ gcc -c main.c -o main.o
$ gcc main.o stack.o -o hello
main.o: In function `main':
main.c:(.text+0x7): undefined reference to `find_in_map'
collect2: ld returned 1 exit status
--// main.c -------------
#include "stack.h"
#include "stdio.h"
int main(){
find_in_map();
return 0;
}
--// stack.h --------------
void find_in_map();
--// stack.cpp -----------
#include <stdio.h>
#include "stack.h"
void find_in_map(){
printf("hello");
}
More information about the Gcc-help
mailing list