I'm not able to use my C/C++ compiler on vscode - visual-studio-code

I followed the gcc compiler installation tutorial for windows from the vscode website: https://code.visualstudio.com/docs/cpp/config-mingw
And the bin folder (C:\msys64\mingw64\bin) is empty, so i'm not able to run the "g++ --version" by adding this path to the Windows path environment variable.
My alternative to it was to use the codeblocks compiler to run my code in vscode, by adding this path: (C:\Program Files\CodeBlocks\MinGW\bin) to the "path" selection in the windows environment variables.
I want to make the MSYS2 compiler work properly in my vscode.
Hope you guys can help me!

MSYS2 comes with a package manager pacman that you should use to install any components you need.
In your case, open the MSYS2 shell (by running mingw64.exe) and run the following commands:
pacman -Syu --noconfirm
pacman -S mingw-w64-x86_64-toolchain
The first command will tell the package manager to update it's database, the second command will get the MinGW-w64 64-bit GCC compiler.
If you don't really need MSYS2 (e.g. because you dan't plan to use the MSYS2 shell) you could also consider getting a standalone MinGW-w64 build from https://winlibs.com/

Related

Visual Studio Code C/C++ Extension cannot find compiler path

Problem:
The program works but the intellisense doesnt recognize the compiler.
Specifications:
I use wsl. Installed from powershell
What i've tried:
I reinstalled both wsl,gcc and vscode and the c/c++ extension
Some Screenshots:
Gcc location in pc
The actual error
what is causes
If you are using Windows, GCC installed on your virtual machine is independant of your primary OS. It seems GCC is installed on your VM. On Ubuntu/Linux, use the following commands to install a GCC compiler:
sudo apt update
sudo apt install build-essential
Furthermore, Visual Studio is simply a text editor. If you want to compile and execute C/C++ on VS, the simplest way is to compile via Powershell on Windows provided you have GCC installed.

Raku: Installation of Gnome::Gtk3 on Windows

I am trying to install the Raku module «Gnome::Gtk3» module on a Windows pc, without success.
Powershell> zef install Gnome::Gtk3
This fails with a lot of "Cannot locate native library"-messages.
I have installed Raku with choco, along with git. And have fixed the path.
That alone took quite some time to figure out, due to missing documentation.
I have installed Gtk, as described here: https://www.gtk.org/docs/installations/windows
But Raku is unable to locate the libraries. Is this something that can work, or do
I have to use the Windows Subsystem for Linux?
(I am aware of the «GTK::Simple» module, but cannot use that as a replacement as it lacks support for keyboard interrupts - which I need.
I have installed it, as it states that it installs the GTK dll's as well.)
In order to make this kind of modules work, you need the -dev version of the library, that is, the DLLs which are actually the ones that NativeCall uses. This tutorial shows how to set them up for C++ and Python, Raku shouldn't be too different.
This now installs on MSYS2, Windows 10. First download the latest version of rakudo from here and extract the zip file to e.g. C:\rakudo-2020.11. Then install MSYS2, and when finished open the MSYS2 terminal window and install the following packages:
$ pacman -Syu
$ pacman -S base-devel gcc git libcrypt-devel libreadline
$ pacman -S mingw-w64-x86_64-gtk3
$ pacman -S mingw-w64-x86_64-toolchain
Then add the following to the MSYS2 ~/.bashrc configuration file:
export PKG_CONFIG_PATH=/mingw64/lib/pkgconfig
export PATH="$PATH:/c/rakudo-2020.11/bin:/c/rakudo-2020.11/share/perl6/site/bin"
export PATH="$PATH:/mingw64/bin"
Save the updated .bashrc and reload it from the MSYS2 terminal prompt:
$ source ~/.bashrc
Finally, install Gnome::Gtk3:
$ zef install Gnome::Gtk3

Clion gdb not found, but working with netbeans

I've seen some other stakoverflow question like this one:
CLion Installation: Cmake compilers not found, GDB not found
But it's not quite the same problem.
My problem is that only my gdb.exe is not found by Clion. I can compile and run programs without problem, but when i need to debug the program tell me that only the debbuger is incorrect.
The problem is that my gbd.exe is present in my cygwin/bin folder
and i have it also in my PATH (system variable)
What i've done so far:
delete, shutdown and reinstall cygwin from scratch.
Install Netbeans and try to run with cygwin config (and debugger) -> everthing is working and i can debug my program. I also try to select it manualy.
So the real question is why Clion think my gdb is not present?
An how can i make it work?
Thank you for your help
Try to install GDB version 7.10.1
My settings:
Short answer: check what versions of gcc, g++ and gdb you have installed. They should be of the same major version.
Long answer:
Try to launch gdb.exe from cygwin terminal. You will probably get something like this (I'm using mingw64 from msys2 so folder will be different):
$ gdb
C:/msys64/mingw64/bin/gdb.exe: error while loading shared libraries: libgcc_s_seh-1.dll:
cannot open shared object file: No such file or directory
But you have gcc installed so you will have this DLL inside C:/msys64/mingw64/bin (in your case folder is different). The problem is that your gdb and gcc are of different major versions. I got this problem when installed mingw-w64-x86_64-gcc-7.3.0-2 with mingw-w64-x86_64-gdb-8.2.1-1. That's why gdb was not able to launch and CLion was not able to check GDB version thus outputting "Not found" error.
If this is the case - remove gdb and install it again. Now with correct major version (same as gcc). Since you're using cygwin, launch cygwin setup again, search for gdb package (don't forget to change view to full) and change version to be the same as gcc. Or, alternatively, you can change gcc version to be the same as gdb (in my case this wasn't possible).

Is it bad to have both MinGW and Msys2 installed?

I have minGW gcc installed on my computer from previous projects, and I have recently installed Msys2 so I could develop with GTK. Is it bad to have MinGW and a instance of MinGW on Msys2 installed on the same computer?
The only problem is that it might confuse you. It should not cause any real issues though, because MSYS2 does not add itself to your PATH environment variable, and when you run MSYS2 it will (by default) use a different PATH so you can only run Microsoft programs in C:\Windows and MSYS2 programs. So this means you won't accidentally run the compiler from one environment when you are in a different environment.

How to run mono commands in msysgit?

I am having trouble running mono CLI commands inside the msysgit console. It works fine in the windows command prompt added by the Mono installer. I have paid attention to the path env variable in the mono command prompt and added C:\Program Files (x86)\Mono\bin\; to the beginning of my system path (and restarted msysgit).
I am getting the following error when trying to run xbuild:
/c/Program Files (x86)/Mono/bin/xbuild: line 2: cygpath: command not found Cannot open assembly 'xbuild.exe': No such file or directory.
What am I missing from msysgit to help mono's CLI tools work better?
Mono for windows is built with cygwin + mingw (see Mono compile guide).
I'm not sure whether it's fully compatible with msys or not. From the error, I guess there is a problem of path. You may need cygpath.exe in your path from the following link. You should probably invoke mono either from Cygwin or cmd (through the bat provided files).
Even if mono for windows is compiled with mingw (and thus should not depend on cygwin), from your error, we can see there are still cygwin dependencies.