【发布时间】:2020-04-26 04:09:30
【问题描述】:
我写了一个程序,在 main 函数中调用另一个 .c 文件中的函数,但输出错误 对“function_name”的未定义引用。 collect2:错误:ld 返回 1 个退出状态。 我在Linux命令行上编译程序:gcc -o main.exe main.c ./main.exe
funcs.h
#ifndef FUNCS_H_INCLUDED
#define FUNCS_H_INCLUDED
int foo();
#endif
秒.c
#include <stdio.h>
#include "funcs.h"
int foo(){
printf("Hello, world!");
return 0;
}
main.c
#include <stdio.h>
#include "funcs.h"
int foo();
int main(){
foo();
return 0;
}
如何修复错误
【问题讨论】:
标签: c