MinGW-w64, QTCreator and gdb installation with MSYS2. Compiler, debugger and IDE installation for programming in C and C++, 32 and 64-bit code.
Adding gdb to MinGW - Stack Overflow
gdb not found when setting up Mingw-64w in VSCode - Stack Overflow
[C++]What is the best way to learn to use GDB with MinGW G++?
I'll never understand these questions. gdb comes with an extensive manual that is very well written. (The pdf version is in many ways easier to read than HTML.) Why would that not be your default starting point?
More on reddit.comVideos
Why MSYS2 and not just install QT from the official website? Because official QT installation on Windows only supports 32-bit code with GCC toolkit.
Everything below is highly recommended to launch with administrator privileges (right mouse click and Run as administrator).
Installation
1.. Download MSYS2 installer here: https://www.msys2.org/ . I recommend x86_64 version, it can work with both x86_64 and i686 code.
2.. Launch installation as administrator and install. Very straightforward installation, just follow it.
3.. After installation the command line window is launched. Wait until you see something like:
admin@MyPC MSYS ~
$If that window is not launched automatically, launch it manually at Start>Programs>MSYS2 64bit>MSYS2 MSYS (launch it as administrator). We have installed MSYS2 on our system.
4.. Now we need to update it. To update it run pacman -Syuu. Currently, there is a bug, you will see:
:: msys2-runtime and catgets are in conflict. Remove catgets? [y/N]
and after also:
:: msys2-runtime and libcatgets are in conflict. Remove libcatgets? [y/N]
on both questions answer y. If you are interested in more information about this issue look here: https://stackoverflow.com/questions/50547051/how-to-resolve-conflict-after-installing-msys2-and-running-pacman-syuu
There can be other questions too but nothing difficult.
5.. If you see:
warning: terminate MSYS2 without returning to shell and check for updates again warning: for example close your terminal window instead of calling exit
Now just close command line window. Window may freeze but it is not a problem. Also you can get a window that says:
Processes are running in session: Close anyway?
press OK. The window may freeze again, just try to close. If there is a window that says Terminal is not responding choose Close the window. If there is a window that asks to terminate the process then terminate it. You can also get some warnings and errors but don't worry, just close these windows.
6.. If you did step 5, launch Start>Programs>MSYS2 64bit as administrator. If there was no step 5 for you just keep working in command line window that is open. Repeat step 4 of this tutorial until you see:
$ pacman -Syuu :: Synchronizing package databases... mingw32 is up to date mingw64 is up to date msys is up to date :: Starting core system upgrade... there is nothing to do :: Starting full system upgrade... there is nothing to do
MSYS2 is now installed and fully updated.
7.. Now we need to install mingw-w64, QT Creator, and gdb. To do that run command:
pacman -S mingw-w64-i686-qt mingw-w64-i686-qt-creator mingw-w64-x86_64-qt mingw-w64-x86_64-qt-creator mingw-w64-i686-gdb mingw-w64-x86_64-gdb
You will be asked which qt version to install, static or non-static.
From: https://softwareengineering.stackexchange.com/a/47339
This only applies if your app is closed source. Can I use an LGPL-licenced library in my commercial app? In short: yes you can. But one important thing to take care of is that the GNU LGPL covered library is dynamically linked, not statically mixed with the main application. It should also be possible to exchange that dynamically linked library for an independently compiled build. Otherwise you have likely intertwingled the library and main application code.
Also, I asked that question on IRC and got the answer:
<vasili111> @Diablo-D3 What about qt version for me? Should I peak static or non-static? <Diablo-D3> depends entirely on what you want to build <vasili111> pick* <Diablo-D3> do you want to build an exe that doesnt require the qt dlls to go with it? then static <Diablo-D3> for dicking around, it doesnt matter which you get <vasili111> So if I want simple programs (hello world and etc) that are single exe files I need to go with static version? <Diablo-D3> yeah
So if you plan to make open source software it does not matter which one you choose. If closed source, choose non-static. I personally choose static version.
Other questions of the installer are easy and answer them appropriately. Installation can take 20-30 mins or even more.
8.. Now and from time to time repeat only steps 4 until you see what is in step 6 and if appears what is in step 5 do as described. After close command line window.
9.. Read "Some problems and solutions you may see" section before!
a. To launch QT Creator to work with 32 bit code:
launch Start>Programs>MSYS2 64bit>MSYS2 MinGW 32-bit with administrator privileges and wait until you see something like:
admin@MyPC MINGW32 ~ $
b. To launch QT Creator to work with 64 bit code:
launch Start>Programs>MSYS2 64bit>MSYS2 MinGW 64-bit with administrator privileges and wait until you see something like:
admin@MyPC MINGW64 ~ $
Now type qtcreator and press enter. QT creator will launch.
10.. Do step 9 to launch QT Creator everytime you need it. Enjoy!
Uninstallation
If you decide to uninstall MSYS2, uninstall it as any other software from Control Panel>Programs and Features. Also if left manually delete msys64 folder (usually it is located at c:\msys64).
If you run uninstall and MSYS2 does not disapears from the installed programs list and/or you get an error window:
An error occurred while trying to uninstall MSYS2 64bit. It may have already been uninstalled. Would you like to remove MSYS2 64bit from the Programs and Features list?
screenshot:
https://i.stack.imgur.com/eOB63.png
Choose Yes. Also if left manually delete msys64 folder (usually it is located at c:\msys64). More about that issue here: https://stackoverflow.com/questions/50545907/how-to-uninstall-msys2
Some problems and solutions you may see
1.. If you create in 32bit QT Creator a project, select 32-bit MinGW kit. If you create in 64bit QT Creator a project, select 64-bit MinGW kit. Otherwise, you can get this issue: https://stackoverflow.com/questions/50570339/error-with-debugging-in-qt-creator-with-dgb-because-of-unknown-signal
2.. It is possible that, in MinGW-w64 32 bit kit by default debugger is set gdp 64 bit which will cause an error when debugging 32 bit code. Check it here in QT creator Tools > Options > Build and Run > Kits https://i.stack.imgur.com/lxcLz.png . You can not change gdp in kit that is installed with the installation. Instead, clone existing 32 bit kit and change gdp 64 bit to gdp 32 bit in cloned kit. Use that clonned kit when creating project for 32 bit code. Some links about that issue: https://stackoverflow.com/questions/50593191/how-to-change-debugger-in-qt-creator and https://github.com/Alexpux/MINGW-packages/issues/3883
Some tips, tricks and other useful info:
To see installed packages: https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#List_of_installed_packages
To search for avaliable package(s): pacman -Ss name_of_package
Other packman commands: https://wiki.archlinux.org/index.php/pacman
Most complete documentation of MSYS2: https://github.com/msys2/msys2/wiki
Some other useful links:
https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2
https://stackoverflow.com/questions/38335424/how-to-use-mingw-64-with-qt-creator/38337759#38337759
https://github.com/msys2/msys2/wiki/MSYS2-installation
Adding clang: https://stackoverflow.com/a/49418743/1601703
I know that my text formatting is not the best also there will be some grammar mistakes. I will appreciate if you correct them both and write result me in PM
Thanks everyone who helped me with dealing setting up everything: OldWolf2, Diablo-D3, jedwardsol, Martchus, Kelteseth, and others from reddit, stackoverflow and IRC.
In a command prompt I browsed to C:\MinGW\bin and ran:
mingw-get.exe install gdb
That fixed it for me. Not sure if it matters but I have C:\MinGW\bin in my path (guess I probably didn't need to browse to C:\MinGW\bin).
The Current Release (5.2.1) version of gdb at the project files page has always worked for me. The download is a stand-alone .exe, you don't need anything else.
But I'll bet the .exe in the 6.8 package will work, too. I'd try using just the .exe, and then if there are problems, try extracting the other files from the 6.8 package. (Though that may cause problems with the rest of the MinGW installation.)
Update: There seems to be a 7.something version. I haven't tested it thoroughly, but it seems to work, even with gcc 3.
No idea what MinGW Installation Manager is or why you were trying to use it when you are using msys2.
To install mingw64 gdb in msys2, you really just need to:
pacman -S mingw-w64-x86_64-gdb
You should probably run pacman -Syu twice before you run the above though.
As you can see, if you need other mingw64 builds of programs (toolchain programs or not), their package names would be prefixed with mingw-w64-x86_64-. There's also the package group mingw-w64-x86_64-toolchain which you can pacman -S --needed instead to get a somewhat full toolchain.
You may also want to use the urt64 toolchain instead. See this page for more details. (You can e.g. pacman -Ss gdb to find out what's the package name prefix for each of the variants.)
Note that to use any of the toolchain (or any non-msys2 builds of programs), you should use the corresponding "launcher" of shell/terminal instead of msys2.exe.
Check by restarting your PC, if it didn't work download the *.gdb file from its website (I guess it's a *.rar or some file), now update with MSYS and restart. It have solved for me, I guess it helps....
- Make sure you have followed the MinGW installation as in https://www.msys2.org/ or if you were using installer from link to installer to install MYSYS then you have to continue from step 5 to install required compiler tools use following command insted of step 6 command
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
You should add the same Installation Folder used in step 3 of installation instruction to the system PATH variable or if you have used installer to install the MinGW find the MinGW installation directory by opening your C drive and add that path to system PATH (in my case Ex: C:\msys64\mingw64\bin)
Make sure the C:\msys64\mingw64\bin is not empty, if it's empty mostly you haven't continued from the step 5 after installing MYSYS from installer
After adding system PATH, close and open cmd window just type path in cmd and enter to make sure your MinGW path is addedd to system PATH, (you can copy paste the output to notepad/notepad++ and search MinGW to find the path)
Once MinGW is in the path your gdb command should work (please provide this screenshot of path command output, if it's still didn't work)
If you install according to https://code.visualstudio.com/docs/cpp/config-mingw, MSYS2.exe direct install.
check if your path: \msys64\mingw64\bin is empty? if it is empty, it shows the gdb is missing. Follow my step 2
open this website, https://packages.msys2.org/packages/mingw-w64-x86_64-gdb, copy the installation comman: pacman -S mingw-w64-x86_64-gdb
open the MSYS2 installed in your computer, past: pacman -S mingw-w64-x86_64-gdb, the comman you copied in step 2.
if you see the path: \msys64\mingw64\bin is filled with files. You're successeful. Open a cmd window, and input: gbd --version.