codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

1、在main函数中调用其他文件中的函数时报错,报错信息如下:

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

2、其中,add函数是我定义在func_a.c中的函数,同时我也已经在main.c中include了"func_a.h"头文件

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

3、网上查找了一些资料以后,发现是因为我没有把func_a.c和func_a.h加入到工程中

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

4、将func_a.c和func_a.h加入到工程,右键项目名,add files,找到文件所在位置,确定,ok

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"

5、再次编译,这次成功了

codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"