Reputation: 59
I'm trying to compile a .c file but I get "undefined reference to" error even though I put the necessary includes. by the way as you can see in the header of my code bellow, I don't have any probleme with #include drive.h, but with #include hardware it's like gcc is ignoring this line.
here is my code and thank you :)
by the way I'm compiling like this: gcc drive.c
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "include/hardware.h"
#include "drive.h"
static void empty_it(){
return ;
}
int main(int argc , char** argv){
unsigned int numCyl ;
unsigned int numSec ;
unsigned char* buffer ;
unsigned int i ;
/* init hardware */
/* on initialise toujours le materiel de la meme facon*/
if(init_hardware("hardware.ini") == 0){
fprintf(stderr, "hardware initialisation error ! \n");
exit(EXIT_FAILURE) ;
}
/* Interrupt handlers */
for(i=0 ;i<16;i++){
IRQVECTOR[i] = empty_it ;
}
/* Allows all IT */
_mask(1);
assert(argc == 3);
numCyl = atoi(argv[1]) ;
numSec = atoi(argv[2]) ;
buffer = malloc(sizeof(char) *HDA_SECTORSIZE);
assert(buffer);
read_sector(numCyl , numSec , buffer);
for(i=0;i<HDA_SECTORSIZE;i++)
printf("%01X\n", buffer[i]);
free(buffer) ;
return EXIT_SUCCESS ;
}
Upvotes: 0
Views: 1711
Reputation: 53006
Including a header file does not add the definition of functions, only their declarations. To add definitions you either:
Your question as it is, doesn't contain the specific information to help you, what is read_sector()
for instance? But the general answer to your current problem is this.
Upvotes: 2