“我正在设置 Visual Studio Code,当我尝试运行 main.cpp(执行时为 main.exe)时,它显示了上述错误。
根据我在网上读到的有关该问题的信息。我认为这是因为 c_cpp_properties.json 文件中写入错误。但我不知道在哪里进行更改。
#Code:
#include <iostream>
int main()
{
std::cout<<"Hello World"<<std::endl;
}
#c_cpp_properties.json :
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
错误信息:
程序“main.exe”无法运行:指定的可执行文件不是此操作系统平台的有效应用程序。行:1 字符:1
+ .\main.exe+ ~~~~~~~~~~。
+ FullQualifiedErrorId:NativeCommandFailed
您收到此错误是因为您正在使用 32 位 cpp.exe 在 64 位 Windows 计算机上构建。所以你正在为不同的目标机器构建。
要解决此问题,请将tasks.json 文件更改为指向g++.exe 而不是cpp.exe。
要在 Windows 上访问tasks.json 文件(ctrl+shift+p),然后输入“tasks”
将 cpp.exe 更改为 g++.exe
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)