1、使用的编译代码:gcc -o a a.c
2、报错信息:
/usr/bin/ld:/usr/lib/gcc/aarch64-linux-gnu/7.3.0/.../.../.../.../lib64/ctr1.o:in function '__wrap_main':
(.text+0x38):undefined reference to 'main'
/usr/bin/ld:/tmp/ccg31g4D.o:in function 'a_collect':
a.c:(.text+0x1a4):undefined reference to 'get_current_a'
/usr/bin/ld:a.c(.text_0x21c):undefined reference to 'str_collect_key_list'
collect2:错误:ld 返回1
3、在a.c中有引用其他的.h文件,这些.h文件中有定义get_current_a和str_collect_key_list,并且.h对应的.c文件,有具体函数的描述。
4、求问:这种问题应该怎么解决?
第一 注意你a.c中有没有main函数
第二 根据你说的这个场景,你在编译的时候,不止要a.c 还需要依赖头文件对应的.c文件,或者链接他的依赖库。
gcc -o a *.c 或者 gcc -o a a.c xxx.c xxx1.c 等试试