我做了以下尝试来为macOS上的C ++建立开发环境,但徒劳无功。
我从Microsoft网站下载了Visual Studio代码并正确安装。
我安装了ms-vscode.cpptools和mitaki28.vscode-clang。
我安装了gdb。
以下是我得到的警告:
ld:警告:忽略文件/ Users / andy / Documents / VS Code C ++ / Hello World / .vscode / tasks.json,文件是为不支持的文件格式而构建的(0x7B 0x0A 0x20 0x20 0x20 0x20 0x22 0x76 0x65 0x72 0x73 0x69 0x6F 0x6E 0x22 0x3A),而不是链接的架构(x86_64):/ Users / andy / Documents / VS Code C ++ / Hello World / .vscode / tasks.json
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
编辑1:我的平台是macOS。
编辑2:当我试图构建最简单的Hello World项目时,发生了我的问题,因此问题不能是我的C ++代码。但是我几乎是一个新手,所以我不知道什么是.json内容。
编辑3:我认为问题可能出在launch.json文件中,所以这是我的文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x64",
"program": "${file}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "g++",
"miDebuggerPath": "/usr/local/bin/gdb"
}
]
}
似乎{somefile}.cpp
您的项目中没有文件(或文件未在编译中),其中包含
int main() {
...
return 0;
}
要么
int main(int argc, char ** argv) {
...
return 0;
}
功能。
您可以放心地忽略task.json警告-它被错误地传递给链接器输入,并且链接器仅忽略该文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句