macOS using Homebrew 'c++' compiler
-
I am working on OSX (Monterey 12.3) and use Qt 6.2.3. The project I am working on requires me to use 'expint()' from the 'math.h' default cpp library. However, clang (the default apple compiler) does not implement this function. Installing gcc from homebrew, and using the 'c++' compiler, I am able to use the 'expint()' function.
Then, modifying the kit to use this compiler causes problems in Qt Creator. When qmake is run I get, ":-1: error: Project ERROR: failed to parse default search paths from compiler output".
When searching for this problem online, all the forums say "Use clang". But, clang won't work for this project. How can I get 'c++' to work?
Thank you in advance -
I am working on OSX (Monterey 12.3) and use Qt 6.2.3. The project I am working on requires me to use 'expint()' from the 'math.h' default cpp library. However, clang (the default apple compiler) does not implement this function. Installing gcc from homebrew, and using the 'c++' compiler, I am able to use the 'expint()' function.
Then, modifying the kit to use this compiler causes problems in Qt Creator. When qmake is run I get, ":-1: error: Project ERROR: failed to parse default search paths from compiler output".
When searching for this problem online, all the forums say "Use clang". But, clang won't work for this project. How can I get 'c++' to work?
Thank you in advance -
@KyleRoth You can't mix C++ compilers. If you want to use GCC as compiler then you will also need to build Qt with this compiler.
@jsulm That is what I'm having trouble with. I was able to install a working compiler on my laptop, and use it outside of Qt. When trying to switch Qt to this compiler, I ran into errors.
How do i 'build' Qt with this compiler?
I had tried going to options>kits>compilers. and adding a new compiler, linked to the one i had downloaded. Then, adding a new kit that used this other compiler. Is this not enough? -
@jsulm That is what I'm having trouble with. I was able to install a working compiler on my laptop, and use it outside of Qt. When trying to switch Qt to this compiler, I ran into errors.
How do i 'build' Qt with this compiler?
I had tried going to options>kits>compilers. and adding a new compiler, linked to the one i had downloaded. Then, adding a new kit that used this other compiler. Is this not enough?@KyleRoth said in macOS using Homebrew 'c++' compiler:
Is this not enough?
No, because you need Qt built with that compiler to be able to create this Kit.
Building Qt is not an easy job:
-
If you want to use a newer version of clang than Apples version then it is really very simple. For example you might do this to have access to OpenMP. Just install llvm with homebrew, then set your cmake CXX and C compiler to point to the homebrew version.