简体   繁体   English

C++ 在 MacOS 上构建失败

[英]C++ build failing on MacOS

I'm trying to run my C++ program on my Macbook and I'm trying to run my program in VSCode by running the build task C/C++:clang++ build active file .我试图在我的 Macbook 上运行我的 C++ 程序,我试图通过运行构建任务C/C++:clang++ build active file在 VSCode 中运行我的程序。 However, every time I do this I get this error ld: can't open output file for writing: /Users/admin/first/first, errno=21 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1 However, every time I do this I get this error ld: can't open output file for writing: /Users/admin/first/first, errno=21 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1

This appears to be a simple permission problem here:这似乎是一个简单的权限问题:

ld: can't open output file for writing ld: 无法打开 output 文件进行写入

The linker cannot write to the file specified. linker 无法写入指定的文件。

Edit : As correctly pointed to by molbdnilo, the error 21 is EISDIR , which means the file you are trying to write to already exists as a directory .编辑:正如 molbdnilo 正确指出的那样, error 21EISDIR ,这意味着您尝试写入的文件已经作为目录存在。 So... just this folder?所以...只是这个文件夹? :) :)

Did you brew install any c++ tools?您是否安装了任何 c++ 工具? Sometimes that is the source of these issues.有时这就是这些问题的根源。 The program is trying to use native OS versions of things when it should use Homebrew's or vice versa.该程序在应该使用 Homebrew 时尝试使用本机操作系统版本,反之亦然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM