【问题标题】:Missing system headers (/usr/include) on macOS CatalinamacOS Catalina 上缺少系统头文件 (/usr/include)
【发布时间】:2019-10-04 08:27:54
【问题描述】:

我刚刚安装了 macOS Catalina 10.15 GM。 不幸的是,我的应用程序框架都没有编译。未找到系统头文件。 在 macOS Mojave 上,有一个解决方法,但它不再有效,文件不会被下载(解决方法解释为 here

当输入xcrun --show-sdk-path 时,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk 会打印在终端上。此文件夹还包含所有必需的标题。我如何告诉 Xcode 使用这些文件?

这就是我的 module.modulemap 的样子:

module PrivateNetwork [system]
{
    header "/usr/include/sys/socketvar.h"
    header "/usr/include/net/if_dl.h"
    header "/usr/include/net/if_types.h"
    header "/usr/include/net/if.h"
    header "/usr/include/netinet/in.h"
    header "/usr/include/netinet/tcp.h"

    header "/usr/include/netinet/tcp_var.h"
    header "/usr/include/netinet/tcpip.h"
    header "/usr/include/netinet/tcp_fsm.h"
    header "/usr/include/netinet/ip.h"
    header "/usr/include/netinet/ip6.h"

    export *
}

错误:Header '/usr/include/sys/socketvar.h' not found

【问题讨论】:

  • 你运行的是什么版本的 Xcode?您是否启动了 Xcode 以安装系统工具?你更新了 Xcode 命令行工具了吗?
  • 是的,我运行了 Xcode 并安装了 CommandLineTools。有人知道我在哪里可以下载旧的 10.14 标头 .pkg 文件吗?
  • 想必你可以在/Applications/Xcode.app/Content/Developer/... 的某个地方看到那些套接字头文件?如果是这样,可能只是修改.modulemap 中的路径。
  • 这行得通(我希望有某种环境变量)但现在我得到了一堆其他错误,比如 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /SDKs/MacOSX10.15.sdk/usr/include/netinet/in_pcb.h:95:18:“in_addr”的定义必须先从模块“Darwin.POSIX.netinet.in”导入。
  • 我对@9​​87654329@s 不是很熟悉,但我现在会进一步研究。查看related errors 看起来它只是另一个所需的头文件,但我不确定。我假设您正在创建用于 swift 的模块映射?

标签: xcode header-files macos-catalina


【解决方案1】:

您可以将 CPATH 设置为头目录。

export CPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/"

【讨论】:

    【解决方案2】:

    为了解决这个问题,我简单地添加了模块映射的完整路径。如果有更好的方法,请告诉我,但至少现在文件可以编译(我还必须重新排序条目):

    module PrivateNetwork [system]
    {
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socketvar.h"
    
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/ip.h"
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/ip6.h"
    
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp_fsm.h"
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp_var.h"
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcpip.h"
    
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if_types.h"
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if.h"
        header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if_dl.h"
    
        export *
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多