homebrew list of available compiler - c++

Hello I need to compile a Qt project using openmp (built using cmake).
Up to now I used gcc-5 provided by homebrew but I would like to use clang (my taste...)
I installed clang-omp via homebrew install clang-omp but now when I try to compile my project (generated via cmake -DCMAKE_CXX_COMPILER=/usr/local/bin/clang-omp++ ..), I get this error:
cd /Users/tommaso/neutrino/debug/src && /usr/local/bin/clang-omp++ -DHAVE_HDF5 -DHAVE_JPEG -DHAVE_LIBCFITSIO -DHAVE_LIBCLFFT -DHAVE_LIBDF -DHAVE_LIBFFTW -DHAVE_LIBFFTW_THREADS -DHAVE_LIBGSL -DHAVE_LIBGSLCBLAS -DHAVE_LIBHDF5HL -DHAVE_LIBMFHDF -DHAVE_LIBNETPBM -DHAVE_LIBTIFF -DHAVE_NPHYSIMAGE -DHAVE_OPENCL -DHAVE_PYTHONQT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -DQT_PRINTSUPPORT_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_UIPLUGIN_LIB -DQT_UITOOLS_LIB -DQT_WIDGETS_LIB -DUSE_QT5 -D__VER=\"osx-cmake-v2.0-75.bdff6e3\" -I/Users/tommaso/neutrino/debug/src -I/Users/tommaso/neutrino/src -I/usr/include/hdf -I/usr/local/include/netpbm -I/Library/Frameworks/qwt.framework/Headers -I/usr/local/Cellar/hdf5/1.8.16_1/include -I/usr/include/python2.7 -I/Users/tommaso/neutrino/src/../../pythonqt-code/src -I/Users/tommaso/neutrino/src/../../pythonqt-code/src/gui -I/Users/tommaso/pythonqt-code/src -I/Users/tommaso/pythonqt-code/extensions/PythonQt_QtAll -I/Users/tommaso/neutrino/src/python -iframework /usr/local/opt/qt5/lib -isystem /usr/local/opt/qt5/lib/QtCore.framework/Headers -isystem /usr/local/opt/qt5/./mkspecs/macx-clang -isystem /usr/local/opt/qt5/lib/QtGui.framework/Headers -isystem /System/Library/Frameworks/OpenGL.framework/Headers -isystem /usr/local/opt/qt5/lib/QtSql.framework/Headers -isystem /usr/local/opt/qt5/lib/QtWidgets.framework/Headers -isystem /usr/local/opt/qt5/lib/QtSvg.framework/Headers -isystem /usr/local/opt/qt5/lib/QtPrintSupport.framework/Headers -isystem /usr/local/opt/qt5/include -isystem /usr/local/opt/qt5/include/QtUiTools -isystem /usr/local/opt/qt5/lib/QtMultimedia.framework/Headers -isystem /usr/local/opt/qt5/lib/QtNetwork.framework/Headers -isystem /usr/local/opt/qt5/lib/QtMultimediaWidgets.framework/Headers -I/Users/tommaso/neutrino/debug -I/Users/tommaso/neutrino/src/graphics -I/Users/tommaso/neutrino/src/doc -I/Users/tommaso/neutrino/src/pans -I/Users/tommaso/neutrino/src/pans/VISAR -I/Users/tommaso/neutrino/src/pans/colorbar -I/Users/tommaso/neutrino/src/pans/winlist -I/Users/tommaso/neutrino/src/../nPhysImage -I/Users/tommaso/neutrino/nPhysImage -isystem /usr/local/opt/qt5/lib/QtUiPlugin.framework/Headers -O3 -fopenmp -fopenmp -O0 -ggdb -D__phys_debug=10 -std=c++11 -Wall -fPIC -mmacosx-version-min=10.6 -o CMakeFiles/Neutrino.dir/neutrino.cc.o -c /Users/tommaso/neutrino/src/neutrino.cc
In file included from /Users/tommaso/neutrino/src/neutrino.cc:26:
In file included from /usr/local/opt/qt5/lib/QtSvg.framework/Headers/QtSvg:3:
In file included from /usr/local/opt/qt5/include/QtSvg/QtSvgDepends:3:
In file included from /usr/local/opt/qt5/include/QtCore/QtCore:4:
In file included from /usr/local/opt/qt5/lib/QtCore.framework/Headers/qabstractanimation.h:37:
In file included from /usr/local/opt/qt5/include/QtCore/qobject.h:41:
/usr/local/opt/qt5/include/QtCore/qstring.h:739:55: error: no type named 'u16string' in namespace 'std'
static inline QString fromStdU16String(const std::u16string &s);
It turns out (correct me if I'm wrong) that I need probably to compile qt with the same clang-omp compiler.
I thought no big deal but homebrew cries when I try this:
HOMEBREW_CC=clang-omp HOMEBREW_CXX=clang-omp++ brew install -s qt5
Error: Invalid value for HOMEBREW_CC: clang-omp
So is there a way to have Qt rebuilt using homebrew?
Is there a command to get the available compilers for homebrew?

Recompiling Qt with a different compiler probably is not going to solve the problem.
Have a look at this other question instead ...
It may also be a bug in Qt's header that can't detect your compiler properly and then wrongly assumes it has support for std::u16string
Or maybe you just forgot to add #include <string>

Related

Error using llvm-11 in combination with standard library headers from gcc-11 compiling with -std=c++2a

I am trying to use clang together with gcc standard library headers as follows:
/opt/rh/llvm-toolset-11.0/root/usr/bin/clang -MD -MF bazel-out/k8-fastbuild/bin/external/com_google_googletest/_objs/gtest/gtest-typed-test.d '-frandom-seed=bazel-out/k8-fastbuild/bin/external/com_google_googletest/_objs/gtest/gtest-typed-test.o' -iquote external/com_google_googletest -iquote bazel-out/k8-fastbuild/bin/external/com_google_googletest -isystem external/com_google_googletest/googlemock -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googlemock -isystem external/com_google_googletest/googlemock/include -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googlemock/include -isystem external/com_google_googletest/googletest -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googletest -isystem external/com_google_googletest/googletest/include -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googletest/include -isystem /opt/rh/devtoolset-11/root/usr/include/c++/11 -isystem /opt/rh/devtoolset-11/root/usr/include/c++/11/bits -isystem /opt/rh/devtoolset-11/root/include/c++/11/x86_64-redhat-linux/bits -fdiagnostics-color -Wfatal-errors '-std=c++2a' -Wall -Wno-sign-compare '--gcc-toolchain=/opt/rh/devtoolset-11/root' -Wheader-guard -pthread -c external/com_google_googletest/googletest/src/gtest-typed-test.cc -o bazel-out/k8-fastbuild/bin/external/com_google_googletest/_objs/gtest/gtest-typed-test.o
Then I get this error:
In file included from external/com_google_googletest/googletest/include/gtest/gtest.h:62:
In file included from external/com_google_googletest/googletest/include/gtest/internal/gtest-internal.h:40:
In file included from external/com_google_googletest/googletest/include/gtest/internal/gtest-port.h:395:
/opt/rh/devtoolset-11/root/usr/include/c++/11/bits/regex.h:56:9: fatal error: use of undeclared identifier 'regex_constants'
regex_constants::match_flag_type __flags);
What could be the reason for the error? Is there an incompatibility between gcc and clang? Should I instead install clang headers and libc++ and is that made by installing package llvm-dev?
The gtest-port.h file includes a file with #include <regex.h> (see here for the code). It expects the file to be the POSIX regex.h which is normally installed directly under the prefix /usr/include. As you can see in the error message, the compiler instead tries to include the /usr/include/c++/11/bits/regex.h which is the wrong file.
The header files in .../bits/ are not meant to be included directly by user code. The are internal to the standard library implementation. Thus it is no surprise to me, that directly including it fails (the missing symbol is probably defined in another internal header file).
To solve your problem I suggest you try to leave out the .../bits directories* in your compile command. I do not know who told you to include them, but they are not meant to be added to the compiler search path.
* drop these two flags from the compiler command line:
-isystem /opt/rh/devtoolset-11/root/usr/include/c++/11/bits
-isystem /opt/rh/devtoolset-11/root/include/c++/11/x86_64-redhat-linux/bits

Building/Linking against Keg (/usr/local/opt) when normal brew package exists in /usr/local

[MacOS Mojave 10.14.5, Xcode 10.2, ROS Kinetic, Qt 5.14.1]
I'm trying to build ROS Kinetic on my Macbook Pro. Certain modules within Kinetic utilise Qt, and I'm having a compilation problem because I have multiple versions of Qt on my system.
I have Qt v5.14.1, a Keg formula which is addressed(linked) through /usr/local/opt/qt, and Qt v4.8.7_6 which is addressed(linked) through /usr/local. I don't want to unlink/uninstall either.
The particular package I'm having difficulties with is qt_gui_cpp which uses CMakeLists.txt files. (Though the package is actually a catkin package, I haven't had any issues using CMake functionality in the make files.)
I'm using Apple's Clang++ compiler, and I think that, based on the types of errors being reported, the compiler is finding the wrong include folder even though the paths in the compiler's error messages is correct for the version I'm using, under the hood. I've tried using set(CMAKE_IGNORE_PATH /usr/local/include) but this hasn't helped.
The actual compiler command that is issued is below. Note that -I/usr/local/include precedes the Qt v5.14.1 include, thus the compiler only looks into the Qt v5.14.1 folder when it can't find it under /usr/local/include:
cd /Users/user/ros/ros_catkin_ws/build_isolated/qt_gui_cpp/src/qt_gui_cpp && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-DQT_CORE_LIB
-DQT_GUI_LIB
-DQT_NO_DEBUG
-DQT_WIDGETS_LIB
-DROS_BUILD_SHARED_LIBS=1
-DROS_PACKAGE_NAME=\"qt_gui_cpp\"
-Dqt_gui_cpp_EXPORTS
-I/Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/include
-I/Users/user/ros/ros_catkin_ws/install_isolated/include
-I/usr/local/include
-I/Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp/qt_gui_cpp
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtCore.framework/Headers
-isystem /usr/local/Cellar/python#2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/include/python2.7
-isystem /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/include/qt_gui_cpp
-isystem /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp
-iframework /usr/local/Cellar/qt/5.14.1/lib
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtWidgets.framework/Headers
-isystem /usr/local/Cellar/qt/5.14.1/lib/QtGui.framework/Headers
-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers
-isystem /usr/local/Cellar/qt/5.14.1/./mkspecs/macx-clang
-I/usr/local/opt/qt/include
-L/usr/local/opt/qt/lib
-fPIC
-O3
-DNDEBUG
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-fPIC
-fPIC
-std=gnu++11
-o CMakeFiles/qt_gui_cpp.dir/composite_plugin_provider.cpp.o
-c /Users/user/ros/ros_catkin_ws/src/qt_gui_core/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp
How can I resolve this problem without breaking other things?
(More info if needed.)

How can I find out which module is adding a given compile flag in Cmake?

I'm facing the following problem: I have a CMake project with a few targets and a multitude of dependencies added via find_package().
I am using set(CMAKE_CXX_STANDARD 11) to compile with C++11, nevertheless somehow, the -std=gnu-14 flag makes it into the command line, which I can see when compiling with CMAKE_VERBOSE_MAKEFILE=1.
/usr/local/opt/ccache/libexec/c++ -DCORE_DEBUG -DDISABLE_LIBUSB_1_0 -DDISABLE_PCAP
-DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB
-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL2)"
-DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)"
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
-Isrc -Ibuild -I/usr/local/include/spinnaker -Ibuild/gtest/src/gtest/googletest/include
-Ibuild/gtest/src/gtest/googlemock/include -isystem /usr/local/include/eigen3 -isystem
/usr/local/Cellar/vtk/8.2.0_1/include/vtk-8.2 -isystem /usr/local/include -isystem
/usr/local/include/pcl-1.9 -isystem /usr/local/Cellar/eigen/3.3.7/include/eigen3
-isystem /Users/ -isystem /usr/local/Cellar/opencv/4.1.0_2/include/opencv4 -isystem
libs/tensorflow/include -isystem /usr/local/Cellar/zeromq/4.3.2/include -iframework
/usr/local/opt/qt/lib -isystem /usr/local/opt/qt/lib/QtWidgets.framework/Headers
-isystem /usr/local/opt/qt/lib/QtGui.framework/Headers -isystem
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers
-isystem /usr/local/opt/qt/lib/QtCore.framework/Headers -isystem
/usr/local/opt/qt/./mkspecs/macx-clang -DPCL_ONLY_CORE_POINT_TYPES=ON
-DNO_EXPLICIT_INSTANTIATIONS -g -g -O0 -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Wno-deprecated-declarations
-Wno-unused-parameter -Wno-sign-compare -std=gnu-c++11 -Wno-unused-private-field -fPIC
-std=gnu++14 -o CMakeFiles/…file1.cpp.o -c src/…file1.cpp
# ^see here
I would like to know where it comes form, as I am not setting it myself. I suspect OpenCV 4.1 and PCL 1.9, but the *_DEFINITIONS properties of the two packages do not include it.
How can I find out who is adding that option and how can I force my own options to be added at the end (regardless of whether that is advisable)?

How do I know what options are being passed to GCC from CMake?

I am trying to build a large open-source project (Clang) that uses CMake in its build system. I am using MinGW64 on Windows.
The command to build is:
cmake --build . --config Debug --target clang
I am having problems with the build so I would like to diagnose what commands are being sent to GCC. For example, I would like to know if -g is set.
How can I see the list of GCC commands that a CMake build triggers?
VERBOSE=1 make | more
example:
[ 14%] Building CXX object public_api/CMakeFiles/secr_api_tests.dir/tests/exception_test.cpp.o
cd /Users/rhodges/secr/netbeans-secr/public_api && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -I/Users/rhodges/secr/secr/public_api/src -I/Users/rhodges/secr/netbeans-secr/public_api/src -I/Users/rhodges/secr/secr/public_api/tests -I/Users/rhodges/secr/netbeans-secr/public_api/tests -isystem /Users/rhodges/secr/secr/public_api/include -isystem /Users/rhodges/secr/netbeans-secr/public_api/include -isystem /Users/rhodges/secr/netbeans-secr/target_local/include -isystem /Users/rhodges/secr/secr/valuelib/debug/include -isystem /Users/rhodges/secr/netbeans-secr/valuelib/debug/include -isystem /Users/rhodges/secr/secr/valuelib/data/include -isystem /Users/rhodges/secr/netbeans-secr/valuelib/data/include -isystem /Users/rhodges/secr/secr/valuelib/tuple/include -isystem /Users/rhodges/secr/netbeans-secr/valuelib/tuple/include -isystem /Users/rhodges/secr/secr/valuelib/immutable/include -isystem /Users/rhodges/secr/netbeans-secr/valuelib/immutable/include -isystem /Users/rhodges/secr/secr/valuelib/stdext/include -isystem /Users/rhodges/secr/netbeans-secr/valuelib/stdext/include -std=gnu++14 -o CMakeFiles/secr_api_tests.dir/tests/exception_test.cpp.o -c /Users/rhodges/secr/secr/public_api/tests/exception_test.cpp
...
As Richard Hodges said, VERBOSE=1 make is the main handy way to do it.
Another is to add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to your CMake call, which will generate a file compile_commands.json with a machine-readable database of compilation flags per file.

QT_VERSION_MAJOR not declared when compiling to 32 bits

I'm working on porting an existing code from Qt4 to Qt5, and compilation works fine on 64 bits (the native system architecture), but fails with a strange error when I try to compile it to 32 bits:
$ QMAKESPEC=linux-g++-32 qmake-qt5
$ make
./create_version.sh
g++ -c -m32 -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DSLT -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -Iinclude -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -I/usr/lib64/qt5/mkspecs/linux-g++-32 -o main.o main.cpp
In file included from /usr/include/qt5/QtCore/qcoreapplication.h:37:0,
from /usr/include/qt5/QtCore/QCoreApplication:1,
from main.cpp:1:
/usr/include/qt5/QtCore/qcoreapplication.h:82:31: error: ‘QT_VERSION_MAJOR’ was not declared in this scope
enum { ApplicationFlags = QT_VERSION
...
I guess this is not related to the code, since the error happens on the first line of my code, which is just an include directive, but don't know how to proceed from here. This is from a Fedora 23 system, if it matters.
The problema was a missing package: qt5-base-devel.i686
After installing it with
sudo dnf install qt5-qtbase-devel.i686
the problem was gone.