3

I'm using Qt Creator and a qmake project. I have what should be a very simple problem:

#include <filesystem>
...
std::filesystem::path myPath;

During the build, as well as in the IDE, I get the error 'path is unavailable: introduced in macOS 10.15'.

I can manually compile just fine with either g++ or clang++ (without using qmake).

My qmake project file has:

TEMPLATE = app
CONFIG += c++17
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += sdk_no_version_check

Is there a magical incantation? I don't even care about the build, as this isn't even a Qt app and I have a manually-produced Makefile. I just don't want the IDE to scream errors at me.

The closest related items I can find on StackOverflow about this talk about link issues. I'm not even getting that far within Qt Creator, although I've tried various suggested flags.

--

I'm doing more digging. I'm manually editing the produced Makefile and running make and getting the same errors out of clang++. I tried g++. Same errors. But normally I build with my own manually-written Makefile, and it's compiling clean.

So I looked at the flags:

-mmacosx-version-min=10.13

Removing that manually gets rid of the error during compilation (from the command line).

So, questions:

  1. How do I get qmake to NOT put that flag in the generated Makefile?

  2. How do I get the linter to not see that flag (I assume that's why it shows up inline in the code editor portion of the IDE)?

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
Joseph Larson
  • 8,530
  • 1
  • 19
  • 36
  • in any case, take a look at: https://stackoverflow.com/a/49192230/5366641 – scopchanov Dec 12 '20 at 02:55
  • @scopchanov Qt Creator is 4.13.3, based on Qt 5.15.2. I had looked at that answer. I don't have a make problem, but an IDE problem. I'm doing the config += c++17 part. – Joseph Larson Dec 13 '20 at 03:26
  • Neither of these is the version of Qt. Anyway, what do you mean by _Qt Creator flags this_? Where do you see the error? – scopchanov Dec 13 '20 at 05:55
  • @scopchanov I'm looking at the "About Qt Creator" page. It says "Qt Creator 4.13.3." Below that it says "Based on Qt 5.15.2 (Clang 11.0 (Apple), 64 bit) Built on Nov 13, 2020. So I don't know what you mean by "neither of these it the version of Qt." As for "flags them" -- it's an IDE. It shows coding errors. That's what makes it more valuable than just using Atom. It shows in big red marks the error I quoted. – Joseph Larson Dec 14 '20 at 15:00
  • And I wish I had an idea what details or clarity is lacking. The only thing I didn't include in the original question was the version of Qt. – Joseph Larson Dec 14 '20 at 15:01
  • 1
    Let me explain. The IDE is not a tool by itself. It is a GUI for various tools. The solutions are different, depending on which tool is complaining. So, if you see the error in the "issues" window, it's the compiler. If you see the errors in-line - it's the linter (a static code analysis tool). From the info you have shared, my best bet would be, that either your compiler or the linter does not support C++17. – scopchanov Dec 14 '20 at 15:53
  • As for _what details or clarity is lacking_, there is no question asked. Please, take a look [here](https://meta.stackoverflow.com/a/284237/5366641). – scopchanov Dec 14 '20 at 15:56
  • @scopchanov Edited with more information at the bottom of the original question. – Joseph Larson Dec 14 '20 at 16:29
  • 1
    And the solution is to add this to the .pro file: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15 – Joseph Larson Dec 14 '20 at 18:37
  • To clarify: None of this has *anything whatsoever* to do with Qt Creator. You don't need the IDE to face this problem at all, and when manually comparing you must compare apples to apples: you must run `qmake` followed by `make`, which would reproduce the issue :) And the linter, *thankfully* sees exactly the same settings the build would see - the last thing you want is for those to diverge. Fix the build and the linter will follow :) In fact, the IDE devotes lots of code to extract the build settings and apply them to the linter - that's on purpose. – Kuba hasn't forgotten Monica Dec 22 '20 at 06:49
  • You should post your solution as an answer and delete the comment - self-answered questions are quite welcome! Re the Qt version: you reported what Qt version was used to build the IDE, which is not very relevant. The IDE supports multiple Qt versions - in fact, it allows builds with Qt 4, Qt 5 and Qt 6, so just looking at the IDE versions it's hard to tell which Qt you're using to build your project against. – Kuba hasn't forgotten Monica Dec 22 '20 at 06:54
  • To get the Qt version you're currently using to build the project (in the current configuration - there may be one or dozens), hover over the project configuration (far left bottom side of Qt Creator's window, where a "monitor" icon is, and below it the word "Release" or "Debug"), and you'll see what Qt version you're building for. You'll see "Project: .... Kit: ...." - the kit is the one that relates to Qt version. – Kuba hasn't forgotten Monica Dec 22 '20 at 06:59

1 Answers1

1

The magical incantation I was searching for turned out to be, in the .pro file:

 QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15

Without that, it was trying to build to support earlier versions of MacOS, which didn't have C++17 features yet.

Joseph Larson
  • 8,530
  • 1
  • 19
  • 36
  • 1
    I would suggest changing that line in `qconfig.pri` under `Qt/VER/macos/mkspecs` so the change happens automatically across all projects. – Matt Eding Feb 27 '22 at 16:27