macOS 命令行工具和 gcc 在 Catalina 上突然失败(在 Mojave 上工作)

标签 macos command-line

命令行工具在尝试安装 MuJoCo 时出现大量错误。我非常有信心地怀疑这是我的 macOS Catalina 上命令行工具的问题,因为我之前已经在 Mojave 和多台 ubuntu 机器上安装了 mujoco。以下安装已在 Mojave 上运行。

首先我执行:

xcode-select --install

更多信息:

(base) ryanr@RRMBP ~ % /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

我使用 pip3 install 'mujoco-py<2.1,>=2.0' 安装

我遇到如下错误:

> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:34:
> error: expected declaration specifiers before
> '__OSX_AVAILABLE_STARTING'    int     getiopolicy_np(int, int)
> __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
>                                     ^~~~~~~~~~~~~~~~~~~~~~~~

  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:144:1: error: expected declaration specifiers before 'div_t'
   div_t  div(int, int) __pure2;
   ^~~~~

In file included from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:34:0,
                   from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/glshim.h:4,
                   from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/dummyshim.c:1:
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:59:19: error: storage class specified for parameter 'float_t'
       typedef float float_t;
                     ^~~~~~~
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:60:20: error: storage class specified for parameter 'double_t'
       typedef double double_t;
                      ^~~~~~~~
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:126:12: error: storage class specified for parameter '__math_errhandling'
   extern int __math_errhandling(void);
              ^~~~~~~~~~~~~~~~~~
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:146:12: error: storage class specified for parameter '__fpclassifyf'
   extern int __fpclassifyf(float);
              ^~~~~~~~~~~~~
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:147:12: error: storage class specified for parameter '__fpclassifyd'
   extern int __fpclassifyd(double);
              ^~~~~~~~~~~~~
  /usr/local/Cellar/gcc@6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:148:12: error: storage class specified for parameter '__fpclassifyl'
   extern int __fpclassifyl(long double);
              ^~~~~~~~~~~~~

                                                  ^
  In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:0,
                   from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:66,
                   from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:33,
                   from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/glshim.h:4,
                   from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:1:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:9: error: old-style parameter declarations in prototyped function definition
   int     getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
           ^~~~~~~~~~~~~~
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
   int     getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
   ^~~
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
  /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:37:1: error: expected '{' at end of input
   }
   ^
  error: command '/usr/local/bin/gcc-6' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for mujoco-py

关于为什么我的命令行工具在 macOS Catalina 上失败有什么建议吗?应该采取哪些步骤来确保 Catalina 上的命令行工具和 gcc 按预期工作?

最佳答案

将以前版本的 OS X sdk 作为 sysroot 传递,而不是未版本化的 sdk。

  1. 由于 SDK 目录不正确,命令行工具在 macOS Catalina 上失败。

  2. 应该采取哪些步骤来确保 Catalina 上的命令行工具和 gcc 按预期工作?引用版本化的 SDK: ./configure --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2 .1 和/或 ./configure --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

关于macOS 命令行工具和 gcc 在 Catalina 上突然失败(在 Mojave 上工作),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58348607/

相关文章:

java - 如何将 jre 打包到 java 应用程序包中?

objective-c - Objective-C : How do i find out if a number is divisible by another number?

windows - 如何从命令行使用 REG_EXPAND_SZ?

linux - 在 Ubuntu 中通过命令行访问 SOAP web 服务

c++ - 如何在 Windows(和 OSX)中进行采样率转换

java - 将 Jackcess 与 JCIFS 结合使用来操作 SMB 共享上的 Access 数据库

Mac崩溃后Android模拟器状态栏渲染困惑

mysql - 具有不同字段终止符的命令行 MySQL 选择

python - 在命令行中将文件名传递给 python 脚本

php - 使用 php 将命令行发送到 Linux 服务器