C++程序出现无法定位程序输入点gxxpersonality_sj0错误解决方法
datehoer 6/23/2022 c++
在vscode中使用run code插件编译执行c++代码时,发现会出现一个错误
#include <iostream>
#include <string>
using namespace std;
int main(){
string greeting = "hello world";
cout << "string:" << greeting << endl;
return 0;
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
我这个代码也是很正常的代码,但是本地运行会出错,一开始以为是代码问题,但是把代码拷贝到菜鸟教程提供的C++在线运行工具上,发现可以正常运行,于是去百度搜了一下“无法定位程序输入点_gxx_personality_sj0”在CSDN发现了解决方法https://blog.csdn.net/qq_43700779/article/details/121891677
文章提供了4个解决方法,但是我只有使用 g++ -static xxx.cpp 编译并运行这个可以正常运行,那么懒得去搞别的方法,怎么去改变呢?
修改vscode 中code runner的执行方法即可
打开扩展设置
选择Executor Map中的在settings.json中编辑。
打开插件编辑
随便找一行输入code就会看到自动提示,找到后缀为.executorMap,之后会把启动方式自动补全
把其余的都删除,只留下cpp即可。
"code-runner.executorMap": {
"cpp": "cd $dir && g++ -static $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
},
1
2
3
2
3
并且在其中增加-static然后保存
之后再右键运行即可正常获取结果。