Just experimenting with including user header file and implementation. And compiling using gcc.
Just a simple program to demostrate. The three files are all seperate files and are in the same directory.
int exchange_rate(int amount);
int exchange_rate(int amount)
return amount * 71;
[root@localhost currency]# gcc currency_app.c -o app
int main(int argc, char *argv)
printf("Welcome to currency exchange\n");
printf("Exchange rate is: %d\n", exchange_rate(10));
/tmp/cciXMhc2.o: In function `main':
currency_app.c.text+0x25): undefined reference to `exchange_rate'
collect2: ld returned 1 exit status
I thought as all the files are in the same directory. It should be able to find them.
I have also compiled currency.c using:
gcc -c currency.c
to create the object file.
Many thanks for any suggestions,