I recently installed MSYS2 on Windows, along with the MinGW-w64 toolchain and CMake. Specifically, I used the following packages:
mingw-w64-i686-gcc
mingw-w64-i686-cmake
make
Trouble is, whenever I invoke CMake from within the MSYS2 shell with cmake -G"MSYS Makefiles", it fails with the following:
target_compile_features no known features for CXX compiler
"GNU"
version 4.9.2.
The line in CMakeLists.txt that generates the error is this: target_compile_features(myproject PUBLIC cxx_decltype).
If I run CMake from outside the MSYS2 shell (I also have it installed separately) with the "MinGW Makefiles" generator, the makefile generation succeeds.
Inside MSYS2, the CMake version is 3.2.3. The version outside is 3.3.0.
Is there any way to resolve this issue? Thanks in advance.
There was bug about interaction of compile features mechanism in CMake 3.3 with gcc 4.8+:
https://public.kitware.com/Bug/view.php?id=15443. It have been fixed several months ago. You need that fix being applied.
Run cmake from mingw64_shell.bat or mingw32_shell.bat. CMake will otherwise pickup msys2 GCC rather than a native one.
Related
I'm currently working on a C++ project that build successfully on Linux using CMake, Make & GCC, and also on Windows using CMake & VS2015.
For some reason, i'd like to build it using the same toolchain everywhere, so i planned to use CMake, Clang & Ninja.
I started to try to build it on Windows, but i did not find any documentation to build using libc++ and without anything from the MSVC toolchain.
Am I forced to install MSVC build tools in order to build with CMake & Clang ?
Use a MinGW-w64 of GCC on Windows (e.g. the one from http://winlibs.com, or any other one listed at http://mingw-w64.org/).
If you combine this with the MSYS2 shell (http://www.msys2.org/), you can build a lot using the same tools as on Linux (autoconf, CMake, meson, ...).
How does one build GDB (the GNU Debugger) from source on Windows? I need to build it in order to make a build with Python support. I cannot use the one distributed with Cygwin because it has problems interpreting backslashes on Windows. What toolchains do I need for the build -- GnuWin32, MinGW, etc.? Can someone please provide step-by-step instructions on how to do this?
install (https://sourceforge.net/downloads/mingw) and configure MinGW with packages g++ gcc libc6-dev libtool pkg-config
get gdb sources (I use 7.latest from https://www.gnu.org/software/gdb/) and put it into MinGW/msys/1.0 folder
run ./configure in msys shell (MinGW\msys\1.0\msys.bat)
run make and fix the following:
hypot compile error with help of this '::hypot' has not been declared
undefined constants for GetLastError function by adding #include <winerror.h> into \gdb\gdbserver\win32-i386-low.c \gdb\gdbserver\win32-low.c gdb\ser-mingw.c
I have checked build process using 7.11.1 and 7.12.1 sources
7.12.1 x32 is broken under windows
https://github.com/Alexpux/MINGW-packages/issues/1909
https://sourceforge.net/p/mingw-w64/bugs/576/
I'm trying an hello world test to make cmake under Windows, using MinGW as compiler.
This answer suggests to run cmake with the -G flag as following:
cmake -G "MinGW Makefiles" .
However, if I do this, I get a message saying that that is not a known generator.
Indeed, running cmake --help, under the Generators section it lists the following generators:
and as you can see, "MinGW Makefiles" is not listed.
If this is relevant, I have MinGW installed and working on my system in the usual folder C:\MinGW. I also have MinGW-w64 installed through WinBuilds and MSYS2, again in the default installation folders.
I'm using cmake version 3.5.2, installed through MSYS2.
Why is "MinGW Makefiles" not listed among the generators?
Only the Windows version of CMake does know the MinGW Makefiles and MSYS Makefiles generators.
If you have downloaded the MinGW/MSYS CMake version try using the Unix Makefiles generator or don't use the -G option (to auto-detect your compiler toolchain).
If you still get errors, please see the references below.
References
cmake MSYS Makefiles generator missing
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I've just build a gcc 5.2.0 on windows according to this material:
http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/
Everything went well. But then I've tried to build Qt with this newly built gcc and I'm getting an error that there is no mingw32-make. Checked directory and no, there isn't one.
But then I checked previously installed gcc, which was work of TDM, downloaded from:
http://tdm-gcc.tdragon.net/
and yes, in his build there is mingw32-make.
So, the question is, how is it that he has that tool, and many other which are absent in my build are present in his?
if you create from the gcc5.2.0 source, a build then you've just created the gcc compiler with all its necessary files. e.g. gcc-5.2.0.exe, gcc.exe, g++.exe, etc.
NOT the MinGW runtime environment for gcc, which contains the mingw32-make.exe !
if you follow your link from your question here you build it with the cygwin make.exe.
It's better to download the mingw 32 binary runtime environment for gcc
or
MinGW64 runtime environment for gcc
Then you have all the files needed to work with QT.
if you want to create a mingw build from source, you need first a MinGW runtime environment then you can use that to build your own mingw32-make.exe.
I would like to set g++4.8 as the c++ compiler with qt creator.
I am in a OSX 10.8, QtCreator 2.8.0, and I have installed g++4.8 via homebrew.
I have setted the g++4.8 as the compiler: if I go in Projects > Manage Kits I have the GCC kit as default, and manually inserted a compiler called GCC 4.8, with compiler path /usr/local/Cellar/gcc48/4.8.1/bin/g++-4.8.
You can see it in the screenshots below. I also have /usr/local/Cellar/gcc48/4.8.1/bin in the Build Enviroment > PATH.
But, if I add QMAKE_CXXFLAGS = --version (I know it is dumb and it doesn't compile but it is just for testing) I receive in the "compiler window"
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1
(that is the same output i receive if I launch g++ from the shell) and not
g++-4.8 (GCC) 4.8.1
(that is what i receive if I launch /usr/local/Cellar/gcc48/4.8.1/bin/g++-4.8 from the shell) (and it is what I want too)
I remember that I had this problem in the past, I tried to resolved it hardlinking the g++4.8 to /usr/bin/g++ but it was not resolved (and just messed up everything).
What can I do?
I had the same problem and landed on your question...
Your question is how to make Qt Creator to use g++-4.8 for compilation.
The solution I devised is the following:
Solution
Add the following line somewhere in your project.pro file
QMAKE_CXX = g++-4.8
for instance just above the HEADERS list
Rationale:
The makefile synthesized by qmake uses the variable CXX to determine the C++ compiler.
You can set the value of the variable CXX at the level of the project configuration file by manually editing it.
Pros:
It solves your problem, you will compile your project using g++-4.8 without having to change the g++ compiler for the rest of your environment.
Cons:
You have to manually set that for each project.
Question for Qt developers:
is there a more natural way to set the g++ compiler at the Kit level? If there is not way, that might be a useful functionality to add.