c++ - launch.json 和 tasks.json 文件设置 ld:未找到架构 x86_64 的符号 clang:错误:链接器命令失败
问题描述
我在编译我的Mystring
(非常简单易行的初学者 C++ 代码)时遇到问题,无法解决此错误:
Error:"ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)"
Warning: "(base) Fans-MBP:Section14 fanyang$ cd "/Users/fanyang/Documents/Tests/Tests/FirstWorkspace/Section14/" && g++ main.cpp -o main && "/Users/fanyang/Documents/Tests/Tests/FirstWorkspace/Section14/"main
In file included from main.cpp:2:
./Mystring.h:30:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Mystring(Mystring &&source);
^
./Mystring.h:34:34: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Mystring &operator=(Mystring &&rhs);
^
./Mystring.h:37:35: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Mystring &operator+=(Mystring &&rhs);"
我正在使用 VSCode(昨天正在使用 Codelite 并切换到 VSCode,现在运行良好的代码无法运行)。
这是我的任务和启动文件:
tasks.json
:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang++ build active file"
}
]
}
解决方案
推荐阅读
- scp - 使用scp将文件从文件发送到IP
- terraform - 在 terraform 文件而不是 env 变量中为 Terraform 提供凭据
- c# - 我怎样才能使这个网格可滚动?
- javascript - keydown 上的多个快捷键在 Typescript 中不起作用
- python - Python 模块安装:指定外部库依赖项的位置
- mongodb - 查找所有位置 $geoWithin $geoIntersects
- reactjs - Heroku 没有连接到 Mongo Atlas DB?
- python - 记录一个协程感知变量
- php - Laravel响应资源png
- python - 通过 SQL Alchemy 错误连接到 Exasol DB