“cc1: error: /usr/local/include: not a directory”安装C库后

时间:2022-08-01 15:07:45

This is the first time I install a library. I followed the instructions here. It's from an online course on programming.

这是我第一次安装库。我按照这里的说明做的。这是一个关于编程的在线课程。

I'm not very Unix savvy. When I tried to compile one of the sample c files, one that #includes the cs50.h file, I get:

我不太了解Unix。当我试图编译一个示例c文件时,其中一个文件#包含cs50。h文件,得到:

cc1: error: /usr/local/include: not a directory

Also, if I write cd /usr/local/include or cd /usr/local/lib, it tells me it's not a directory again, even though when I ls /usr/local they both show up.

另外,如果我写cd /usr/local/include或cd /usr/local/lib,它会告诉我它不再是一个目录,即使当我写ls /usr/local时它们都出现了。

Any ideas?

什么好主意吗?

1 个解决方案

#1


3  

Given that the instructions in the header are:

考虑到标题中的说明是:

  • To compile as a static library on your own system:
  • 在您自己的系统上以静态库形式编译:
  • % gcc -c -ggdb -std=c99 cs50.c -o cs50.o
  • % gcc -c -ggdb -std=c99 cs50。c - o cs50.o
  • % ar rcs libcs50.a cs50.o
  • % ar rcs libcs50。一个cs50.o
  • % rm -f cs50.o
  • % rm - f cs50.o
  • % cp cs50.h /usr/local/include
  • % cp cs50。h /usr/local/include
  • % cp libcs50.a /usr/local/lib
  • % cp libcs50。一个/usr/local/lib

Note the use of '%' as a prompt. It indicates that the operations should be done as root.

注意使用'%'作为提示符。它指示操作应该作为根进行。

Unless your system is misconfigured, you will need to use root privileges to copy the files into the directories under /usr/local. For example, you might use sudo as a prefix to the commands:

除非您的系统被错误配置,否则您将需要使用root权限将文件复制到/usr/local下的目录中。例如,可以使用sudo作为命令的前缀:

sudo cp cs50.h /usr/local/include
sudo cp libcs50.a /usr/local/lib

We can deduce (with fairly high confidence) that you did not already have directories /usr/local/include and /usr/local/lib, and that you now have two files (not directories) called:

我们可以相当有信心地推断,您还没有目录/usr/local/include和/usr/local/lib,并且您现在有两个文件(不是目录):

  • /usr/local/include that contains the header cs50.h
  • /usr/local/include包含头cs50.h
  • /usr/local/lib that contains the static library
  • 包含静态库的/usr/local/lib

You should validate this observation with ls -l /usr/local and perhaps file /usr/local/*. Then you should remove the files, create the directories, and copy the files into the newly created directories.

您应该使用ls -l /usr/local或者文件/usr/local/*来验证这个观察。然后您应该删除文件,创建目录,并将文件复制到新创建的目录中。

The only thing this explanation does not account for is the missing leading slash in the error message (which originally said 'cc1: error: usr/local/include: not a directory'). At the moment, I put that down to a transcription error in asking this question. (And a comment and edit confirms that diagnosis.)

这个解释唯一没有说明的是错误消息(错误消息中最初说的是“cc1: error: usr/local/include: not a directory”)中缺少的前斜杠。现在,我把这个问题归结为转录错误。(评论和编辑证实了这一诊断。)

#1


3  

Given that the instructions in the header are:

考虑到标题中的说明是:

  • To compile as a static library on your own system:
  • 在您自己的系统上以静态库形式编译:
  • % gcc -c -ggdb -std=c99 cs50.c -o cs50.o
  • % gcc -c -ggdb -std=c99 cs50。c - o cs50.o
  • % ar rcs libcs50.a cs50.o
  • % ar rcs libcs50。一个cs50.o
  • % rm -f cs50.o
  • % rm - f cs50.o
  • % cp cs50.h /usr/local/include
  • % cp cs50。h /usr/local/include
  • % cp libcs50.a /usr/local/lib
  • % cp libcs50。一个/usr/local/lib

Note the use of '%' as a prompt. It indicates that the operations should be done as root.

注意使用'%'作为提示符。它指示操作应该作为根进行。

Unless your system is misconfigured, you will need to use root privileges to copy the files into the directories under /usr/local. For example, you might use sudo as a prefix to the commands:

除非您的系统被错误配置,否则您将需要使用root权限将文件复制到/usr/local下的目录中。例如,可以使用sudo作为命令的前缀:

sudo cp cs50.h /usr/local/include
sudo cp libcs50.a /usr/local/lib

We can deduce (with fairly high confidence) that you did not already have directories /usr/local/include and /usr/local/lib, and that you now have two files (not directories) called:

我们可以相当有信心地推断,您还没有目录/usr/local/include和/usr/local/lib,并且您现在有两个文件(不是目录):

  • /usr/local/include that contains the header cs50.h
  • /usr/local/include包含头cs50.h
  • /usr/local/lib that contains the static library
  • 包含静态库的/usr/local/lib

You should validate this observation with ls -l /usr/local and perhaps file /usr/local/*. Then you should remove the files, create the directories, and copy the files into the newly created directories.

您应该使用ls -l /usr/local或者文件/usr/local/*来验证这个观察。然后您应该删除文件,创建目录,并将文件复制到新创建的目录中。

The only thing this explanation does not account for is the missing leading slash in the error message (which originally said 'cc1: error: usr/local/include: not a directory'). At the moment, I put that down to a transcription error in asking this question. (And a comment and edit confirms that diagnosis.)

这个解释唯一没有说明的是错误消息(错误消息中最初说的是“cc1: error: usr/local/include: not a directory”)中缺少的前斜杠。现在,我把这个问题归结为转录错误。(评论和编辑证实了这一诊断。)