Hello,
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.
Code:
//currency.h
int exchange_rate(int amount);
Code:
//currency.c implementation
#include "currency.h"
int exchange_rate(int amount)
{
return amount * 71;
}
Code:
#include <stdio.h>
#include "currency.h"
int main(int argc, char *argv[])
{
printf("Welcome to currency exchange\n");
printf("Exchange rate is: %d\n", exchange_rate(10));
return 0;
}
[root@localhost currency]# gcc currency_app.c -o app
/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,
Steve
[/code]