Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msys2 doesn't find mingw64

I downloaded:

https://mingw-w64.org/doku.php/download/mingw-builds

https://mingw-w64.org/doku.php/download/msys2

and installed them under C:/development/msys64. Under this folder I find the msys2.exe and the mingw64 folder, which in turn contains the bin one with all the mingw executable.

I added C:/development/msys64/mingw64/bin folder to the PATH env var. In fact from a Windows prompt I can invoke the gcc - for example. Instead inside the msys2 shell I cannot find them. I mean, they are in /mingw64/bin but they are not available at prompt.

I'm sure I missed some steps!

like image 701
Mark Avatar asked Jan 16 '17 10:01

Mark


2 Answers

Method to switch from MinGW-w32 to MinGW-w64

  • Download the executable file of MinGW-w64 Refer the EDIT

(Executable file link may change for future releases, this is for Version 8.1.0, Kindly cross verify the latest version before installing from this link)

  • Installation Process (In Settings):
Version: PICK LATEST
Architecture: x86_64
Threads: posix
Exception: seh

If anyone is trying to add MinGW-w64 as a PATH variable and is not able to find the gdb.exe in C:\msys64\mingw64\bin, try looking for it in the Program files.

C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin

The gdb.exe and other files are located in this directory.


EDIT:

After making some changes in the launch.json file in VSCode, the MinGW-w64 GDB debugger started giving errors because there was 2 versions of MinGW in different folders i.e, MINGW and mingw64!

It is essential that the installation path does not contain any spaces
(i.e., space in "Program Files"), this will create conflicts later.

STEPS:

1. Uninstalled all the versions of GCC that was installed in the PC - Cygwin, MSYS2(32 bit) and mingw64(64 bit) and installed the MinGW-w64 again, this time using the MSYS2.

Please start afresh, if debugger is giving errors and if versions are clashing!

2. Download the MSYS2 installer from this link.

Install process is simple, follow the steps mentioned in the website!

It is essential that the installation path does not contain any spaces. Therefore, we cannot install MinGW-w64 in Program Files.

3. After Installation is complete: Open MSYS2 terminal (pink icon).

Update the package database and base packages using:

pacman -Syu

After this, Update rest of the base packages using:

pacman -Su

4. Now switch over to MSYS2 MinGW 64-bit terminal (blue icon).

To install gcc and g++ for C and C++.

For 64 bit:

pacman -S mingw-w64-x86_64-gcc

To install debugger (gdb).

For 64 bit:

pacman -S mingw-w64-x86_64-gdb

5. Now you're all SET!

Check versions:

gcc --version
g++ --version
gdb --version

6. Finally, remove the old environment variables if any are left and add the new environment variable to the PATH!

BEFORE DEBUGGING FILES IN VSCode, MAKE SURE TO ADD -g tag while building, otherwise breakpoints will be ignored by the debugger!

Footnote: It's very important to keep all the versions in one folder, if folders are different, then life will get tough later!

like image 168
Vishnu Avatar answered Oct 16 '22 04:10

Vishnu


MSYS2 has packages for its own GCC toolchains and you would probably be better off using those toolchains instead of downloading a different one. For example, to use a 64-bit MinGW GCC, you would have to run pacman -S x86_64-w64-mingw32-toolchain and then make sure you are starting MSYS2 using the "MinGW-w64 64-bit Shell" shortcut (or something like that) so that /mingw64/bin is on your PATH.

Also, MSYS2 does not respect your system or user environment variables; it uses its own PATH by default.

like image 31
David Grayson Avatar answered Oct 16 '22 04:10

David Grayson