skip to Main Content

I’m trying to generate an iOS Xcode project from CMake. First, I generate the project and it does it fine without any error. Once it’s generated, I try to build it with the following command:

cmake --build _builds --config Release --target install

And that’s when I get the errors. What I’m thinking is that is due to some kind of incompatibility with the c++ version of the library that I’m using and the compiler; but I’m not sure about it. These are the errors that I get from running the build command:

/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});

This is what I get from running:

g++ --version

Result:

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

2

Answers


  1. check the version of g++.

    g++ --version
    

    your code is run above >= c++11.

    Login or Signup to reply.
  2. If you have access to the CMakeLists.txt file, add:

    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    

    This ensures all subprojects are also build in C++17. If you can’t change the CMakeLists.txt file for some reason, you can pass the compiler flag in the command line at configure time:

    cmake -S . -B _builds -DCMAKE_CXX_FLAGS="-std=c++17"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search