错误一:目标文件未成功链接到该函数HelloFunc所在的库文件或者未安装该库文件
CMakeFiles/hello.dir/main.c.o:在函数‘main’中:
main.c:(.text+0xa):对‘HelloFunc’未定义的引用
collect2: error: ld returned 1 exit status
src/CMakeFiles/hello.dir/build.make:96: recipe for target ‘src/hello’ failed
make[2]: *** [src/hello] Error 1
CMakeFiles/Makefile2:97: recipe for target ‘src/CMakeFiles/hello.dir/all’ failed
make[1]: *** [src/CMakeFiles/hello.dir/all] Error 2
Makefile:90: recipe for target ‘all’ failed
make: *** [all] Error 2
错误二:主工程CMakeLists.txt的头文件搜索路径, 未包含函数HelloFunc所在的头文件
~/cmake/t6/src/main.c:1:10: fatal error: hello.h: 没有那个文件或目录
#include <hello.h>
^~~~~~~~~
compilation terminated.
src/CMakeFiles/hello.dir/build.make:75: recipe for target ‘src/CMakeFiles/hello.dir/main.c.o’ failed
make[2]: *** [src/CMakeFiles/hello.dir/main.c.o] Error 1
CMakeFiles/Makefile2:97: recipe for target ‘src/CMakeFiles/hello.dir/all’ failed
make[1]: *** [src/CMakeFiles/hello.dir/all] Error 2
Makefile:90: recipe for target ‘all’ failed
make: *** [all] Error 2