我正在尝试几个小时来开始锻炼,我在开始时堆叠!请帮助!
我的代码是这样的:
的main.c
#include <stdio.h>
#include "heap.h"
#include "BF.h"
int main() {
char *myfile;
myfile = "file1";
HP_Create(myfile);
return 0;
}
BF.c
void Init(){
blabla...
}
int BF_Create(const char* filename){
blabla...
}
void PrintError(const char* message){
blabla...
}
BF.h
#ifndef BF_H_
#define BF_H_
void Init();
int BF_Create(const char* filename);
void PrintError(const char* message);
#endif
heap.c
#include "BF.h"
#include "heap.h"
#include <stdlib.h>
int HP_Create(char *fileName) {
Init();
if (BF_Create(fileName) < 0) {
PrintError("Error creating file");
exit(EXIT_FAILURE);
return -1;
}
return 0;
}
heap.h
int HP_Create(char *fileName);
我执行:
gcc -o example main.c BF.c heap.c
我收到以下错误:
heap.c:(.text+0x12): undefined reference to `Init'
heap.c:(.text+0x1e): undefined reference to `BF_Create'
heap.c:(.text+0x2c): undefined reference to `PrintError'