gpt4 book ai didi

c++ - 让 llvm/clang(来自 brew)在 OSX 上工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:03:45 25 4
gpt4 key购买 nike

使用 brew install llvm 安装 llvm

我有一个简单的文件,例如:


int main() {
std::cout << "Ain't this a fine pickle ?" << std::endl;
}

我在运行:

/usr/local/opt/llvm/bin/clang++ -I/usr/local/opt/llvm/include -I/usr/local/opt/llvm/include/c++/v1 -L/usr/local/opt/llvm/lib main.cpp

我明白了:

In file included from main.cpp:1:
In file included from /usr/local/opt/llvm/include/c++/v1/iostream:38:
In file included from /usr/local/opt/llvm/include/c++/v1/ios:215:
In file included from /usr/local/opt/llvm/include/c++/v1/iosfwd:90:
/usr/local/opt/llvm/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.

有什么线索吗?

编辑: 我尝试运行 sudo xcode-select --switch/Library/Developer/CommandLineTools/ 因为在其他地方提到过,但它没有改变任何东西。

编辑:按照建议尝试获取有关头文件位置的信息:

> $ echo '#include <wchar.h>' | /usr/local/opt/llvm/bin/clang++ -I/usr/local/opt/llvm/include -I/usr/local/opt/llvm/include/c++/v1 -L/usr/local/opt/llvm/lib -E -H -xc++ -
clang-7: warning: argument unused during compilation: '-L/usr/local/opt/llvm/lib' [-Wunused-command-line-argument]
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 399 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
# 1 "/usr/local/opt/llvm/include/c++/v1/wchar.h" 1 3
. /usr/local/opt/llvm/include/c++/v1/wchar.h
# 109 "/usr/local/opt/llvm/include/c++/v1/wchar.h" 3
# 1 "/usr/local/opt/llvm/include/c++/v1/__config" 1 3
.. /usr/local/opt/llvm/include/c++/v1/__config
# 22 "/usr/local/opt/llvm/include/c++/v1/__config" 3
# 475 "/usr/local/opt/llvm/include/c++/v1/__config" 3
namespace std {
inline namespace __1 {
}
}
# 110 "/usr/local/opt/llvm/include/c++/v1/wchar.h" 2 3
# 113 "/usr/local/opt/llvm/include/c++/v1/wchar.h" 3
In file included from <stdin>:1:
/usr/local/opt/llvm/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
# 135 "/usr/local/opt/llvm/include/c++/v1/wchar.h" 3
extern "C++" {
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__))
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}

inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__))
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcspbrk(__s1, __s2);}

inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__))
wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return __libcpp_wcsrchr(__s, __c);}

inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__))
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return __libcpp_wcsstr(__s1, __s2);}

inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__))
wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
inline __attribute__ ((__visibility__("hidden"))) __attribute__ ((__always_inline__)) __attribute__ ((__enable_if__(true, "")))
wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
}
# 2 "<stdin>" 2

1 error generated.

我可以看到我在其中指定包含路径的文件:

> $ l /usr/local/opt/llvm/include/c++/v1/wchar.h
-rw-r--r-- 1 abrahma staff 8.2K Dec 7 12:42 /usr/local/opt/llvm/include/c++/v1/wchar.h

最佳答案

最终起作用的是:

  • 打开/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
  • 按照提示安装包
  • 在此之后,您应该会看到 /usr/include 出现
  • 现在 clang++ 从 brew 安装就可以了

(归功于 this note )

关于c++ - 让 llvm/clang(来自 brew)在 OSX 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54656480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com