macOS Catalina上缺少系统标头(/ usr / include)

时间:2019-10-04 08:27:54

标签: xcode header-files macos-catalina

我刚刚安装了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

2 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:0)

要解决此问题,我只需将完整路径添加到modulemap中。如果有更好的方法,请让我知道,但至少现在文件可以编译(我还必须重新排序条目):

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 *
}