Visual code says compiler is not recognized - gcc

I downloaded visual code 1.60.2 for windows 7 . My pc has 32 bit operating system.When i downloaded vs code and ran the code it shows up"'gcc' is not recognized as internal or external command".
Please tell me what should i do.

You have to install a MINGW Environment in order to use gcc with Windows.
Steps:
Install C/C++ extension for VS Code
Install Mingw-w64
Add mingw bin path to your PATH variable in windows.
If you have already installed the extension and mingw, you forgot to add it to the path variable. Validate this with opening a Commandline or Powershell an call:
g++ --version
Here is a detailed guide how to do this: Using GCC with MinGW

Related

How to configure msys2 in codeblocks?

How to configure codeblocks compiler and debugger with msys2 ?
I found an answer related here, but I don't find very usefull as I use windows 7, instead linux ;)
What I want to achive is integrating esp-idf embedded system in codeblocks.
Is this even possible ? Anyone ?
Install CodeBlocks 20.03 without the compiler (installer: codeblocks-20.03-setup.exe, about 37.5 Mb)
Download and install Msys2 by following the instructions on the homepage
Install the mingw-w64 toolchain (open the Msys64 shell and run the command: pacman -S git mingw-w64-x86_64-cmake make mingw-w64-x86_64-toolchain)
Now you need to configure the compiler in CodeBlocks.
Go to Settings -> Compiler...
Click on Toolchain executables tab and browse for mingw64 folder (without bin).
Edit the executable file names as gcc.exe, g++.exe and g++.exe
Click Ok to confirm
Go to Settings -> Debugger... and configure gdb.exe as default debugger (browse for the gdb.exe file into the bin directory)
Now the GCC compiler and the GDB debugger are configured.
You can use pacman from the Msys2 shell, to download and install or uninstall a lot of packages.
I don't know esp-idf but it seems to me that this sdk is not distributed as a msys2 package.

Perl6 NativeCall cannot locate symbol in native library

I have a module using NativeCall that works on both Linux and macOS, but not Windows. When I try to use the module on Windows I get lots of errors like:
# Cannot locate symbol 'TinyTIFFReader_open' in native library 'tinytiff.dll'
I use cmake for my C++ dependency on all three OS's. On Linux and macOS I can just cmake ..; make; sudo make install, and on Windows I cmake -G "Visual Studio 15 2017 Win64" .. and then open the created ".sln" in Visual Studio to compile. The build succeeds with no errors on all three OS's.
Does anyone have any ideas of what I would need to do/change to also get my module working on Windows?
The full module is located here: https://github.com/ryn1x/Graphics-TinyTIFF
I think you will have to give TINYTIFFREADER_LIB_EXPORT and TINYTIFFWRITER_LIB_EXPORT defines a value (either in the source, but probably better to have it be passed by the build system) and on windows i think it has to be __declspec(dllexport), otherwise the symbols may not be made available in the dll.

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!
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!
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.

Compiling Qt using MinGW on Win64 - which MinGW?

Based on these instructions I'm trying to install/compile Qt 4.8.6 on Windows 7x64 using MinGW 4.8.2. Per those instructions I went to get MinGW from this site, which leads me to win-builds.org.
The result is that I have a directory filled with various mingw executables: x86_64-w64-mingw32-c++.exe, x86_64-w64-mingw32-g++-4.8.2.exe, x86_64-w64-mingw32-g++.exe, x86_64-w64-mingw32-gcc-4.8.2.exe, x86_64-w64-mingw32-gcc-ar-4.8.2.exe, x86_64-w64-mingw32-gcc-nm-4.8.2.exe, x86_64-w64-mingw32-gcc-ranlib-4.8.2.exe, x86_64-w64-mingw32-gcc.exe.
When I go to install Qt, it asks where MinGW is:
But when I supply the path to all those executables, it says that it cannot find g++:
Do I need to alias one of those executables to a different name for Qt to find it?
As I only noticed when posting the above screenshot, the Qt installer is adding an extra \bin to the path. Giving it the location of the parent folder of the executables worked, in my case just:
C:\Program Files\Utilities\winbuild

LLVM MinGW installation on Vista?

From llvm.org I've downloaded llvm-2.6-x86-mingw32.tar.bz2 into c:\llvm and llvm-gcc-4.2-2.6-x86-mingw32-tar.bz2 into c:\llvm-gcc as well as setup a desktop shortcut the following batch file in c:\llvm-gcc which attempts to setup an environment for compiling via the llvm-gcc command line too:
#echo off
color 0E
echo Configuring LLVM environment...
set LLVM_LIB_SEARCH_PATH=%~dp0lib
set PATH=c:\llvm;%~dp0bin;%PATH%
Unfortunately, this setup gives the following error when trying to compile a simple hello world program:
C:\CDev\sandbox>llvm-gcc -o hello.exe hello.c
llvm-gcc: CreateProcess: No such file or directory
I've briefly looked through the LLVM binaries and it appears that the MinGW-based Win32 API and runtime files are already included. I also tried adding the MinGW DLL to c:\llvm-gcc\bin to no avail.
What have I missed in setting up the binary LLVM environment and GCC-based front end on Vista?
Thanks, Jon
Because the GNU/MinGW assembler 'as' was required by 'llvm-gcc' to generate the obj file. The problem can be solved by using:
Install GNU/MinGW binutils, extract the as.exe into c:\llvm-gcc\bin
Install a full MinGW package, add %MinGW%\bin your %PATH%
#rwallace is correct that one needs to also install MinGW's binutils along with the LLVM binary download. I've updated the LLVM documentation appropriately at
http://llvm.org/docs/GettingStarted.html#installcf
As far as I can tell, the answer is that the MinGW distribution supplied by LLVM is not complete, in particular, it doesn't come with the 'binutils' programs.
The recommended solution seems to be to download and install MinGW yourself. However, the MinGW download page seems to be saying this requires 10 different packages to be downloaded and installed separately.
The solution I tried today was to use the MinGW that comes with Qt, which does come in a single package; thus far, that appears to work.
It seems like it is looking for the base MinGW installation in C:\MinGW. I just had this error today using gcc.exe in msys. To solve it, I created a symbolic link from c:\msys to c:\MinGW and everything worked.

Resources