Hi!
I have a problem. I try to compile a simple "template" C program with the three classic files: main.c, fonctions.h and fonctions.c. I always work this way for many years on many IDE and I never had any compilation problem. But I tried to do the same at the command line in FreeBSD in a directory under root and I always get an "undefined reference" to the fonction1 in my fonctions.c file. Yet, all my files are ok because they compile and work very well in an IDE like Netbean.
Here's my template files:
main.c
fonctions.h
fonctions.c
I'm sure this code is ok but the cc and gcc command at the command line of FreeBSD don't find the fonction1 in fonction.c. All the files are in the same directory. I tried also a Makefile with a make depend, it doesn't work either.
Can anyone have an answer?
Thanks!
I have a problem. I try to compile a simple "template" C program with the three classic files: main.c, fonctions.h and fonctions.c. I always work this way for many years on many IDE and I never had any compilation problem. But I tried to do the same at the command line in FreeBSD in a directory under root and I always get an "undefined reference" to the fonction1 in my fonctions.c file. Yet, all my files are ok because they compile and work very well in an IDE like Netbean.
Here's my template files:
main.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include "fonctions.h"
int main(void)
{
fonction1();
return 0;
}
fonctions.h
Code:
#ifndef FONCTIONS_H_INCLUDED
#define FONCTIONS_H_INCLUDED
int fonction1(void);
#endif
fonctions.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include "fonctions.h"
int fonction1(void)
{
printf("Hello world!");
return 0;
}
Can anyone have an answer?
Thanks!