Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;与库的兼容性_C++_Ios_Xcode_Cmake - Fatal编程技术网

C++ C++;与库的兼容性

C++ C++;与库的兼容性,c++,ios,xcode,cmake,C++,Ios,Xcode,Cmake,我正试图从CMake生成一个iOS Xcode项目。首先,我生成了这个项目,它做得很好,没有任何错误。生成后,我尝试使用以下命令构建它: cmake --build _builds --config Release --target install 这就是我得到错误的时候。我的想法是,这是由于我与使用的库的C++版本和编译器的不兼容;但我不确定。以下是运行build命令时出现的错误: /Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/

我正试图从CMake生成一个iOS Xcode项目。首先,我生成了这个项目,它做得很好,没有任何错误。生成后,我尝试使用以下命令构建它:

cmake --build _builds --config Release --target install
这就是我得到错误的时候。我的想法是,这是由于我与使用的库的C++版本和编译器的不兼容;但我不确定。以下是运行build命令时出现的错误:

/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/utils.hh:77:14: error: expression is not an integral
      constant expression
        case Code::NONE:
             ^~~~~~~~~~
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:42:1: error: unknown type name
      'constexpr'
constexpr  auto         ab_generators = std::array<unsigned,12>
^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:42:25: error: illegal storage class on
      file-scoped variable
constexpr  auto         ab_generators = std::array<unsigned,12>
                        ^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:43:3: error: expected '(' for
      function-style cast or type construction
  {
  ^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:48:1: error: unknown type name
      'constexpr'
constexpr  unsigned int ab_rate       = ab_generators.size();
^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:49:1: error: unknown type name
      'constexpr'
constexpr  unsigned int order         = 15;
^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:62:1: error: unknown type name
      'constexpr'
constexpr  unsigned int state_count = (1 << order);
^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:63:1: error: unknown type name
      'constexpr'
constexpr  unsigned int state_mask  = (1 << order) - 1;
^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:70:12: error: expression is not an
      integral constant expression
      case ConvBlockType::a:
           ^~~~~~~~~~~~~~~~
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:71:12: error: expression is not an
      integral constant expression
      case ConvBlockType::b:  return (msg_size + order) * ab_rate / 2;
           ^~~~~~~~~~~~~~~~
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:72:12: error: expression is not an
      integral constant expression
      case ConvBlockType::ab: return (msg_size + order) * ab_rate;
           ^~~~~~~~~~~~~~~~~
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:143:27: error: a space is required
      between consecutive right angle brackets (use '> >')
  vector<vector<StateEntry>> error_count;
                          ^~
                          > >
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:143:17: warning: template argument uses
      local type 'StateEntry' [-Wlocal-type-template-args]
  vector<vector<StateEntry>> error_count;
                ^~~~~~~~~~
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:145:55: error: expected '(' for
      function-style cast or type construction
    error_count.emplace_back (state_count, StateEntry {0, -1, 0});
                                           ~~~~~~~~~~ ^
/Users/edwardpizzurro/Desktop/watermark-lib/audiowmark/convcode.cc:145:17: error: no member named
      'emplace_back' in 'std::__1::vector<std::__1::vector<StateEntry, std::__1::allocator<StateEntry> >,
      std::__1::allocator<std::__1::vector<StateEntry, std::__1::allocator<StateEntry> > > >'; did you mean
      '__emplace_back'?
    error_count.emplace_back (state_count, StateEntry {0, -1, 0});
结果:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

检查g++的版本

g++ --version

您的代码在>=c++11以上运行。

如果您有权访问CMakeLists.txt文件,请添加:

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
这确保了所有子项目都是在C++17中构建的。如果由于某种原因无法更改CMakeLists.txt文件,可以在配置时在命令行中传递编译器标志:

cmake -S . -B _builds -DCMAKE_CXX_FLAGS="-std=c++17"

代码至少是用C++11编写的。你在编译吗?我不知道如何检查我的CMAD编译的版本,查看版本。指定C++版本,而不是CopySeri用运行命令的结果更新问题。我不确定它对Metheop的问题是问如何将编译器选项设置为C++11,而不是如何检查正在使用的版本。作为对该问题的后续评论,这会更好。
cmake -S . -B _builds -DCMAKE_CXX_FLAGS="-std=c++17"