函数份文件编写,多个cpp文件没有同时编译
Undefined symbols for architecture x86_64:
"swap_test(int, int)", referenced from:
_main in main-323346.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
其实原因是vscode默认设置是值编译了当前文件,而未编译其他引用文件,所以swap_test函数未编译。
解决方案
1. 编辑runcode的配置文件
打开Code>>首选项>>配置,搜索run code,找到Code-runner Executor Map,如下图
2. 编辑runcode配置文件
点击在settings.json中编辑,得到以下默认配置
这里$fileName只是当前文件进行了编译
所以我们只需要编译所有文件即可。
保存运行,即可
版权声明:本文为weixin_42618420原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。