简体   繁体   English

clang编译器无法在终端Mac OSX上运行

[英]clang compiler not working on terminal Mac OSX

I just upgraded to El Capitan and found out that the C compiler (Clang) is not working under the command line. 我刚刚升级到El Capitan,发现C编译器(Clang)在命令行下不起作用。 I wrote a "hello word" test, tried to compile and I get the following error: 我编写了一个“ hello word”测试,尝试进行编译,但出现以下错误:

$ cc test.c -o test $ cc test.c -o测试

$ error: unable to open output file $错误:无法打开输出文件

  '/var/folders/Ge/GeRStfi8Ek8jojLcqf1vsE+++TI/-Tmp-/test-ad7039.o': 'No

  such file or directory'

1 error generated. 产生1个错误。

... do I have a permission problems somewhere? ...我在某处有权限问题吗? Thanks! 谢谢!

Either you're running into permissions problems (the compiler is unable to create a folder inside var , and so there's no such file or directory) or the ability to open the file in the current directory of compilation isn't allowed. 您可能遇到权限问题(编译器无法在var内创建文件夹,因此没有此类文件或目录),或者不允许在当前编译目录中打开文件。 Check your permissions on 检查您的权限

  • The file 文件
  • The directory 目录

Run the command under sudo . sudo下运行命令。 If that fixes your problem, then use ls -la to check your permissions in the current folder. 如果这样可以解决您的问题,请使用ls -la检查您在当前文件夹中的权限。 Then, use chown or chmod to change the permissions on the file/folder. 然后,使用chownchmod更改文件/文件夹上的权限。

Example: 例:

chown owner-user test.c

Now, you may actually not actually have access to the /var/ folder. 现在,您实际上可能实际上没有权限访问/ var /文件夹。 If so, then the temp folder cc is creating is the problem. 如果是这样,则问题是cc正在创建临时文件夹。 So then, you'd sudo call cc . 因此,您将sudo调用cc For a more permanent fix, you can chown the binary or directory clang is in. 对于更永久性的修复,可以chown二进制或目录clang在不在。

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

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