/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
由于错误输入,这条指令这是将VecAdd.cpp编译成名为main.cpp的可执行文件,而VecAdd.cpp中实现的是向量加法函数vecAdd,该源文件并没有主函数main(),于是就出现了"undefined reference to main"的链接器报错。
可以通过使用IDE、编写shell脚本、使用cmake工具等更安全的工具,从而减少这样的失误带来的问题。