【问题标题】:"unknown type name 'decltype'": Installing pyicu on mac failed, with gcc error“未知类型名称'decltype'”:在mac上安装pyicu失败,出现gcc错误
【发布时间】:2018-02-05 10:48:31
【问题描述】:

我运行了以下命令(因为我的 mac 上有 python2 和 python3):

$ CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib sudo python3 -m pip install pyicu

错误信息如下:

安装收集的包:pyicu 为 pyicu 运行 setup.py install ... 错误 命令的完整输出 /anaconda3/bin/python3 -u -c "import setuptools, tokenize;file='/private/tmp/pip-build-l71tm0m4/pyicu/setup.py';f= getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close(); exec(compile(code, file, 'exec'))" install --record /tmp/pip-7298jccr-record/install-record.txt --single-version-externally-managed --编译:

Building PyICU 2.0.3 for ICU 58.2

Adding CXXFLAGS="-I/anaconda3/include" from /anaconda3/bin/icu-config
Adding LDFLAGS="-Wl,-rpath,/anaconda3/lib -L/anaconda3/lib -licui18n -licuuc -licudata" from /anaconda3/bin/icu-config
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
copying PyICU.py -> build/lib.macosx-10.7-x86_64-3.6
creating build/lib.macosx-10.7-x86_64-3.6/icu
copying icu/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/icu
running build_ext
building '_icu' extension
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/anaconda3/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.7-x86_64-3.6/_icu.o -DPYICU_VER="2.0.3" -I/anaconda3/include
In file included from _icu.cpp:27:
./common.h:38:13: error: unknown type name 'decltype'
    typedef decltype(nullptr) nullptr_t;
            ^
./common.h:38:30: error: expected ';' after top level declarator
    typedef decltype(nullptr) nullptr_t;
                             ^
                             ;
2 errors generated.
error: command 'gcc' failed with exit status 1

----------------------------------------

Command "/anaconda3/bin/python3 -u -c "import setuptools, tokenize;file='/private/tmp/pip-build-l71tm0m4/pyicu/setup.py';f =getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close() ;exec(compile(code, file, 'exec'))" install --record /tmp/pip-7298jccr-record/install-record.txt --single-version-externally-managed - -compile" 失败,错误代码 1 在 /private/tmp/pip-build-l71tm0m4/pyicu/

【问题讨论】:

  • 您可能需要将-stdc=c++11 添加到您的CFLAGS。请注意sudo 默认情况下会丢弃大多数环境变量,因此您可能需要执行sudo su,然后从根shell 运行CFLAGS=... python...
  • @n.m.谢谢!有用。但它是-std=c++11

标签: python macos gcc pip pyicu


【解决方案1】:

根据@n.m.,-std=c++11 需要添加到 CFLAGS。

【讨论】:

    猜你喜欢
    • 2016-06-05
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    相关资源
    最近更新 更多