- #include"lisi.h"
- #include <stdio.h>
- int main ()
- {
- int c = sum(2,3);
-
- printf("%d\n",c);
- return 0;
- }
复制代码
这是wangwu.c文件
- int sum(int a,int b)
- {
- return a+b;
- }
复制代码
这是lisi.c文件
- #ifndef LISI_H
- #define LISI_H
- int sum(int a,int b);
- #endif
复制代码
这是lisi.h文件
为什么运行时报错???
错误是:
localhost:10-其他 mazhihua$ cc wangwu.c
Undefined symbols for architecture x86_64:
"_sum", referenced from:
_main in wangwu-0c8122.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
localhost:10-其他 mazhihua$
|
|