gunnar13
March 28th, 2009, 06:08 PM
Probably a very simple question, but I did some FAQ searching without great results.
Situation: I have some c functions that work well, and I was trying to use them from a c++ main.
Here is an absolutely simplified scenario:
Three files, fie.h, fie.c and foo.cc
Content of fie.h:
int fie(void);
Content of fie.c:
#include <fie.h>
int fie(void)
{
return(13);
}
Content of foo.cc:
#include <cstdio>
#include <fie.h>
main()
{
int a;
a = fie();
printf("The c function returned %d \n", a);
}
using
gcc -c -I. fie.c
gcc -c -I. foo.cc
I now have two object files
using
gcc -o foo -I. -lstdc++ fie.o foo.o
I get the linker error
/tmp/ccbpROH5.o: In function `main':
foo.cc:(.text+0x12): undefined reference to `fie()'
Ok, so the linker can't resolve the refferrence.
How would I do this?
Thanks
Situation: I have some c functions that work well, and I was trying to use them from a c++ main.
Here is an absolutely simplified scenario:
Three files, fie.h, fie.c and foo.cc
Content of fie.h:
int fie(void);
Content of fie.c:
#include <fie.h>
int fie(void)
{
return(13);
}
Content of foo.cc:
#include <cstdio>
#include <fie.h>
main()
{
int a;
a = fie();
printf("The c function returned %d \n", a);
}
using
gcc -c -I. fie.c
gcc -c -I. foo.cc
I now have two object files
using
gcc -o foo -I. -lstdc++ fie.o foo.o
I get the linker error
/tmp/ccbpROH5.o: In function `main':
foo.cc:(.text+0x12): undefined reference to `fie()'
Ok, so the linker can't resolve the refferrence.
How would I do this?
Thanks