PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, June 26, 2022

[FIXED] How to fix "Qt requires a C++17 compiler" error?

 June 26, 2022     cgal, compiler-errors, gcc, macos, qt     No comments   

Issue

I installed with brew the CGAL C++ library. After doing cmake . in the first basic example , I do make and I got a sequence of errors, the first one and most important is:

/usr/local/include/QtCore/qglobal.h:96:6: error: "Qt requires a C++17 compiler"
#    error "Qt requires a C++17 compiler"
     ^

which means that I need a way to tell Qt to use a C++17 compiler. How can I fix this? I'm an engineer, and I've never faced a similar issue before. There have been similar questions before (like this) but they're about Windows.

I'm using a MacOS BigSur, 11.6.2. and gcc --version returns

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

Solution

Actually, you will need to tell cmake to activate c++17 support in the compiler commands it generates. By default, Apple clang was chosen, and that comes with an earlier default std support.

cmake -DCMAKE_CXX_FLAGS="-std=c++17" .

If for whatever reason you intended to compile with the gcc wrapper or some other compiler, you can let cmake know:

cmake -DCMAKE_CXX_COMPILER="gcc" -DCMAKE_CXX_FLAGS="-std=c++17" .


Answered By - Richard Barber
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing