在 macOS 10.15.6 上编译 Apache ORC 时出错

Posted

技术标签:

【中文标题】在 macOS 10.15.6 上编译 Apache ORC 时出错【英文标题】:Errors when compiling Apache ORC on macOS 10.15.6 【发布时间】:2020-09-20 22:57:35 【问题描述】:

我正在我的 macOS Catalina 10.15.6(使用 Apple clang 版本 12.0.0 (clang-1200.0.32.2))上编译 Apache ORC,这里有一些错误。请问是什么原因造成的?

(base) karlkatzen@chloes build % make package testout
[  6%] Built target protobuf_ep
[ 11%] Built target lz4_ep
[ 17%] Built target libhdfspp_ep
[ 23%] Built target googletest_ep
[ 28%] Built target snappy_ep
[ 34%] Built target zstd_ep
[ 39%] Built target zlib_ep
[ 39%] Building CXX object c++/src/CMakeFiles/orc.dir/io/InputStream.cc.o
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.cc:20:
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.hh:22:
/Users/karlkatzen/Documents/code/orc/c++/src/Adaptor.hh:177:9: error: keyword is
      hidden by macro definition [-Werror,-Wkeyword-macro]
#define constexpr const
    ^
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.cc:20:
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.hh:23:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/OrcFile.hh:25:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/Reader.hh:22:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/BloomFilter.hh:25:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:274:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:145:49: error: 
      cannot specify any part of a return type in the declaration of a
      conversion function; put the complete type after 'operator'
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
                                            ^~~~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:152:5: error: 
      constructor cannot have a return type
    _LIBCPP_CONSTEXPR
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__config:887:29: note: 
  expanded from macro '_LIBCPP_CONSTEXPR'
#  define _LIBCPP_CONSTEXPR constexpr
                        ^
/Users/karlkatzen/Documents/code/orc/c++/src/Adaptor.hh:177:19: note: expanded
  from macro 'constexpr'
#define constexpr const
              ^
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.cc:20:
In file included from /Users/karlkatzen/Documents/code/orc/c++/src/io/InputStream.hh:23:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/OrcFile.hh:25:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/Reader.hh:23:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/Common.hh:22:
In file included from /Users/karlkatzen/Documents/code/orc/c++/include/orc/Vector.hh:32:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:37:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:215:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:208:31: error: 
  constructor cannot have a return type
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) 

附:以下是我运行 cmake 的方式:cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..

【问题讨论】:

问题的根源是源代码使用了marco,这是一个C++关键字名称,是一个警告,并且类的构造函数有返回类型,这是语法错误。 Apache ORC 的确切版本是什么?你修改过源代码吗? 【参考方案1】:

_LIBCPP_CONSTEXPR 是 LibCxx 标准库编译器定义。 你的兽人库代码的定义与编译器定义冲突,所以在这个文件中/Users/karlkatzen/Documents/code/orc/c++/src/Adaptor.hh:177:9: error: keyword is hidden by macro definition [-Werror,-Wkeyword-macro] #define constexpr const 只需评论此行#define constexpr const

【讨论】:

以上是关于在 macOS 10.15.6 上编译 Apache ORC 时出错的主要内容,如果未能解决你的问题,请参考以下文章

在MacOS系统上编译OpenJDK12并使用CLion调试

在 macOS 上编译 XDR 时出现问题(RPC types.h 问题)

macOS 上编译 Dynamips

在MacOS上编译Tilde文本编辑器

SDL2 无法在 macos Big Sur 上编译

在 mac os 上编译 dlib