msys2 doesn't find mingw64 - windows

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.

Related

Installing Make in Cygwin

I am trying to build a Linux project in windows 7 environment usign cygwin. However I am continuously getting below error while configuring make for cygwin installation.
-bash: make: command not found
After searching on inernet the only solution is re running of setup and installed make package. I have installed automake1.15 but it is in noarch folder and there is no binary make.exe in bin folder.
run command setup-x86_64.exe -q --packages=make(because make is not installed) in command prompt where the setup-x86_64.exe file is available
There's a big difference between the 2:
[GNU]: Automake - Generates Makefile templates
[GNU]: GNU Make - Builds software from sources (via Makefiles)
So you need to select Make from Cygwin setup.
Notes:
Automake (or any package, as a matter of fact) is downloaded in the noarch dir, when it's compatible with any OS (Cygwin, in this case) architecture (32 bit and 64 bit (currently)), meaning that it doesn't contain binaries (.exes, .dlls (.sos)), only script-like files
Make on the other hand, does contain binaries (/usr/bin/make itself it is a binary) and will be downloaded in the appropriate dir (x86_64 or x86)
The download dir is not the same thing as the installation dir (there may be more than one, and it's under Cygwin installation dir)
For more (generic) details, check [Cygwin]: Installing and Updating Cygwin Packages.
[Cygwin]: Cygwin FAQ - Does the Cygwin Setup program accept command-line arguments? might also be a good starting point for command line options (check [SO]: Installing Make in Cygwin (#PJain's answer)).
Final note: Cygwin is kind of obsolete. Switch to WSL(2), which runs a real Ubuntu (no wrappers / adapters) as a VM (in Hyper-V - which runs at a totally different level).

Step by step instruction to install Rust and Cargo for mingw with Msys2?

I tried to install Rust on Cygwin but failed to be able link with mingw. Now I am trying to install it with Msys2. I already installed Msys2 and Mingw. I tried to follow this wiki page but I got lost at number 2:
Download and install Rust+Cargo using the installer but be sure to disable the Linker and platform libraries option.
Is it referring to the "rustup-init.exe" on the install page? Should I double click to run this file or run it from Msys2? I tried to run from Msys2 and got the options:
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
I don't know what to do next.
The Using Rust on Windows page you linked to dates from before rustup replaced the installer as the default option to install Rust. Installers are still available, but you should use rustup if possible, because it makes it easy to update and to use multiple toolchains at once (e.g. stable, beta and nightly). If you must use the installer, just select the x86_64-pc-windows-gnu installer and follow the step from the Using Rust on Windows page. If you're using rustup, read on.
By default, rustup on Windows installs the compiler and tools targeting the MSVC toolchain, rather than the GNU/MinGW-w64 toolchain. At the initial menu, select 2) Customize installation. When asked for a host triple, enter x86_64-pc-windows-gnu. Then make a choice for the other questions, then proceed with the installation.
Note: If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run rustup toolchain install stable-x86_64-pc-windows-gnu if you already have the MSVC-based toolchain. Then run rustup default stable-x86_64-pc-windows-gnu to set the GNU-based toolchain as the default.
Rustup will install the MinGW linker and platform libraries automatically (as part of the rust-mingw component) and refuses to let you remove them. If you prefer to use the MinGW linker and libraries you installed with MSYS2, you'll need to create a .cargo/config file (either in your profile directory, i.e. C:\Users\you\.cargo\config, or in your project's directory if this configuration is specific to a project). The contents of that file might look like this:
[target.x86_64-pc-windows-gnu]
linker = "C:\\msys2\\mingw64\\bin\\gcc.exe"
ar = "C:\\msys2\\mingw64\\bin\\ar.exe"
Rustup will modify the PATH environment variable unless you told it not to. However, MSYS2 resets PATH by default when you launch, so when you try to invoke cargo or rustc from your MSYS2 shell, it might not find it. You'll need to edit your .profile/.bash_profile script to set the PATH correctly (you need to prepend /c/Users/yourname/.cargo/bin: to PATH).
my problem resolved by following way
Run rustup toolchain install stable-x86_64-pc-windows-gnu
Second open .rustup folder
Open settings.toml file
Change first line with: default_toolchain = "stable-x86_64-pc-windows-gnu"
done!
I wrote a complete guide on how to
install Rust on windows with Visual Studio Code and MSYS2 MinGW
on the page found here:
https://stackoverflow.com/a/68835925/4230643

Installing gfortran in Linux as a user

I am a non-administrator user of a Linux (CentOS 6.6) server at work. I log in through a terminal program on a windows computer. My problem is that the IT does not feel comfortable upgrading GCC/gfortran for me so I want to just run it from my personal folders. They claim the latest yum (devtoolset-3 for this OS version) will downgrade some other feature they have. It's not the latest version of GCC anyway.
I have downloaded the latest GCC 5.3 binaries and prerequisites from gfortran.com and can almost get my test code to compile. Actually, when I do the following it will compile with -c but will not not link. That folder is where I put the prerequisites and also I copied stuff from the /usr/lib64 directory into there as well.
LD_LIBRARY_PATH=/users/home/me/me/gcc53mark/my_lib
export LD_LIBRARY_PATH
./gfortran test.f90
The error message is as follows:
collect2: fatal error: cannot find 'ld'
But ld does exist
-bash-4.1$ whereis ld
ld: /usr/bin/ld /usr/share/man/man1/ld.1.gz
After much effort I have answered my own question! To install GCC to my own personal Linux account as a non-administrator, I ended up having to compile GCC and not use the binaries I originally downloaded. My friend was make install which knows where everything needs to go, which I did not have with the binaries.
The key was to install to my user root directory /GCC with the following command provided with the build-it-yourself method (-prefix):
../gcc-5.3.0/configure --prefix$HOME/gcc-5.3.0 --enable-languages=c,c++,fortran --disable-multilib
For me I had to disable multilib because I guess my system only has 64 bit libraries (I think this was causing my original problem).
Before I got to that point, I had to also download the prerequisites manually since my workplace I suppose blocks the automatic prerequisite downloader as referenced in these instructions.
https://gcc.gnu.org/wiki/InstallingGCC
Prerequisites need to be taken from here, placed into the root of the directory that gets created when you unzip GCC. Then unzip them and link them as is done in the batch file you have already unzipped ./contrib/download_prerequisites.
ftp://gcc.gnu.org/pub/gcc/infrastructure/
Finally I need to run the following command, after it is all up so it looks at the new libraries. I will add this to my .profile when I am ready to fully switch to the local newer version.
LD_LIBRARY_PATH=/users/home/myself/gcc-5.3.0/lib64
export LD_LIBRARY_PATH
For now I am running gfortran with the following command but also I will add this to my .profile later.
/users/home/myself/gcc-5.3.0/bin/gfortran Test.f90
It works! Latest version of GCC running from my local Linux user non-administrator account!
Edited to add how we resolved this for the network group:
IT did not want to overwrite the original installation so we installed to some network folder /gcc-5.3.0 . Then we modified the group's .profile to add the library and binary paths to that, before the standard path.

how to use cmake that installed in a non-standard path?

I am on Ubuntu 14.04.3 platform. While I was compiling a project it asked cmake version 3.2 which is not present in my system. I compiled the latest version of cmake from source code and installed it into /usr/local/bin directory. When I attempt to compile project again, its cmake detects the cmake in /usr/bin which is lower version. Then cmake ..
process aborts with lower version error. Is there any built-in cmake variable or environment variable for setting path of the cmake?
EDIT:
I just found a cmake variable CMAKE_COMMAND that supposedly does what I want.
But when I insert CMAKE_COMMAND = /usr/local/bin/cmake line into cmakelist.txt then I go to build directory and issue /usr/local/bin/cmake ..
I get :
Expected a command name, got unquoted argument with text
I searched for it on the net but didn't find a solution.
If you have different versions of a software or library installed you may use stow to install and switch between the two. Especially if you want to install a newer version of a software that is not available in one's Linux distribution. So in case the new version is not yet stable you can still switch to the previous one. For example while building cmake 3.2 you can specify the prefix as
./configure --prefix=/usr/local/stow/cmake-3.2/
and then
cd /usr/local/stow
sudo stow cmake-3.2
and if you want to remove the links you can use the following command
sudo stow --delete cmake-3.2
Please keep in mind stow does not delete files. It only makes and deletes links.

How to install pkg config in windows?

I am trying to do it, but all I can get is some source code that I don't know how to do deal with I downloaded from http://pkgconfig.freedesktop.org/releases/.
This is a step-by-step procedure to get pkg-config working on Windows, based on my experience, using the info from Oliver Zendel's comment.
I assume here that MinGW was installed to C:\MinGW. There were multiple versions of the packages available, and in each case I just downloaded the latest version.
go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
download the file pkg-config_0.26-1_win32.zip
extract the file bin/pkg-config.exe to C:\MinGW\bin
download the file gettext-runtime_0.18.1.1-2_win32.zip
extract the file bin/intl.dll to C:\MinGW\bin
go to http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28
download the file glib_2.28.8-1_win32.zip
extract the file bin/libglib-2.0-0.dll to C:\MinGW\bin
Now CMake will be able to use pkg-config if it is configured to use MinGW.
Get the precompiled binaries from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
Download pkg-config and its depend libraries :
pkg-config_0.26-1_win32.zip
glib_2.28.8-1_win32.zip
gettext-runtime_0.18.1.1-2_win32.zip
A alternative without glib dependency is pkg-config-lite.
Extract pkg-config.exe from the archive and put it in your path.
Nowdays this package is available using chocolatey, then it could be installed with
choco install pkgconfiglite
I did this by installing Cygwin64 from this link https://www.cygwin.com/
Then - View Full, Search gcc and scroll down to find pkg-config.
Click on icon to select latest version.
This worked for me well.
I would like to extend the answer of #dzintars about the Cygwin version of pkg-config in that focus how should one use it properly with CMake, because I see various comments about CMake in this topic.
I have experienced many troubles with CMake + Cygwin's pkg-config and I want to share my experience how to avoid them.
1. The symlink C:/Cygwin64/bin/pkg-config -> pkgconf.exe does not work in Windows console.
It is not a native Windows .lnk symlink and it won't be callable in Windows console cmd.exe even if you add ".;" to your %PATHEXT% (see https://www.mail-archive.com/cygwin#cygwin.com/msg104088.html).
It won't work from CMake, because CMake calls pkg-config with the method execute_process() (FindPkgConfig.cmake) which opens a new cmd.exe.
Solution: Add -DPKG_CONFIG_EXECUTABLE=C:/Cygwin64/bin/pkgconf.exe to the CMake command line (or set it in CMakeLists.txt).
2. Cygwin's pkg-config recognizes only Cygwin paths in PKG_CONFIG_PATH (no Windows paths).
For example, on my system the .pc files are located in C:\Cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\lib\pkgconfig. The following three paths are valid, but only path C works in PKG_CONFIG_PATH:
A) c:/Cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
B) /c/cygdrive/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
C) /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - works.
Solution: add .pc files location always as a Cygwin path into PKG_CONFIG_PATH.
3) CMake converts forward slashes to backslashes in PKG_CONFIG_PATH on Cygwin.
It happens due to the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21629. It prevents using the workaround described in [2].
Solution: manually update the function _pkg_set_path_internal() in the file C:/Program Files/CMake/share/cmake-3.x/Modules/FindPkgConfig.cmake. Comment/remove the line:
file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
4) CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH have no effect on pkg-config in Cygwin.
Reason: the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21775.
Solution: Use only PKG_CONFIG_PATH as an environment variable if you run CMake builds on Cygwin. Forget about CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH.
Install mingw64 from https://sourceforge.net/projects/mingw-w64/. Avoid program files/(x86) folder for installation. Ex. c:/mingw-w64
Download pkg-config__win64.zip from here
Extract above zip file and copy paste all the files from pkg-config/bin folder to mingw-w64. In my case its 'C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin'
Now set path = C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
taddaaa you are done.
If you find any security issue then follow steps as well
Search for windows defender security center in system
Navigate to apps & browser control> Exploit protection settings> Program setting> Click on '+add program customize'
Select add program by name
Enter program name: pkgconf.exe
OK
Now check all the settings and set it all the settings to off and apply.
Thats DONE!
Another place where you can get more updated binaries can be found at Fedora Build System site. Direct link to mingw-pkg-config package is: http://koji.fedoraproject.org/koji/buildinfo?buildID=354619
for w64-based computers you have to install mingw64. If pkg-config.exe is missing then, you can refer to http://ftp.acc.umu.se/pub/gnome/binaries/win64/dependencies/
Unzip and copy/merge pkg-config.exe into your C:\mingw-w64 installation, eg. into on my pc into C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
In 2022 VS Code works with CMake & pkgconfig out of the box (add pkgconf && vcpkg-pkgconfig-get-modules to your vcpkg.json)
From: https://github.com/JoinMarket-Org/joinmarket/wiki/Installing-JoinMarket-on-Windows
This guide describes how to install JoinMarket and its dependencies (python, libsodium, secp256k1) on Windows.
Some or all of this may or may not work for all versions of Windows. Reports appreciated. It is not claimed to be in any way comprehensive. Verification of downloads are your own responsibility.
Install JoinMarket - go to https://github.com/JoinMarket-Org/joinmarket/releases and download the most recent release. Unzip it into any location you choose.
You will need to install MinGW from here or go to their website. After a few introductory screens, you will be shown a windows with some optional components that you have to choose; this basic setup is sufficient:
From "Basic Setup" in the left menu:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
Once you have chosen these, choose "Update" from the main menu first item. These components will be installed into C:\MinGW\bin. Once that is complete, you should have this dll: libgcc_s_dw2-1.dll in that folder C:\MinGW\bin, along with a lot of other files; I'm mentioning this file explicitly, since it's needed specifically for libsecp256k1 to operate in this setup.
Next, you must make sure C:\MinGW\bin is added to your PATH variable. Here's one guide to how to do that; you must append ;C:\MinGW\bin to the end of the path before continuing.
Install Python from https://www.python.org/ftp/python/2.7.11/python-2.7.11.msi. Run the executable. Choose to install the feature Add python.exe to Path (it's the last option in the installer, off by default - switch it on) on local hard drive during installation; Python should then be installed in C:\Python27 (EXTRA NOTE: the most recent 2.7 installation linked here seems to install pip automatically, which is very useful for step 4)
Check that Python runs. Open a new command prompt as administrator by typing cmd.exe into the Start menu and pressing Ctrl+Shift+Enter. Type python and you should see something like:
Python 2.7.11 (default....
....
>>>
Exit the Python console with exit() or by pressing Ctrl+C. Now, make sure your version of pip is up to date: run the command: python -m pip install --upgrade pip.
Go to the directory C:\Python27\Lib\distutils and add a new file, called distutils.cfg. Inside it, put:
[build]
compiler=mingw32
Close and save the file.
Next, you need to install the dll for libnacl. First go to https://download.libsodium.org/libsodium/releases/ and choose the file libsodium-1.0.4-msvc.zip to download. Unzip anywhere, and then copy the file libsodium.dll from the directory \Win32\Release\v120\dynamic (do not use v140), and paste it into root joinmarket directory (the same directory where README.md lives). Then you need to address the Visual C++ 2013 runtime dependency. Do so by going to www.microsoft.com/en-us/download/details.aspx?id=40784 and clicking Download. Choose x86 even on a 64-bit system, and run the executable.
Note that after doing this, you must run pip install -r requirements-windows.txt from the Joinmarket root directory (where the README.md file is) and should not get an error message (this will install/check the python packages libnacl and secp256k1(-transient)).

Resources