Downgrading MSYS2 to a specific Mingw / gcc version - mingw-w64

I have MSYS2 64 bit installed in my system.
When I try to check the gcc version, I am getting the following output.
$ gcc --version
gcc.exe (Rev9, Built by MSYS2 project) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
But I want to use a specific mingw version for my project which uses qt library.
When I check my build log and installation folder of my qt project I found this.
|Project name: DataManager
|Project version: undefined
|C++ compiler for the host machine: ccache c++ (gcc 4.9.2 "c++ (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 4.9.2")
|C++ linker for the host machine: c++ ld.bfd 2.24
|Program python3 found: YES
|Found qmake: C:\Qt\5.6.3\mingw49_32\bin\qmake.EXE (5.6.3)
I am assuming that it uses mingw49_32 version and gcc version 4.9.2.
I would like to use the same gcc version (4.9.2) in MSYS2.
How can I achieve it ?

You can't do that with MSYS2. Old packages are eventually removed from MSYS2 repos, so even if it had GCC 4.9 at some point in the past, it no longer does. The earliest available version is GCC 9.3.
Even if it was in the repo, you'd have to manually download and install it and all its dependencies, since there's no way to download outdated packages directly from pacman.
But, I suspect that:
You already have GCC 4.9 installed in C:\Qt\5.6.3\mingw49_32\bin.
Even if you don't, you might be able to get away with using an up-to-date GCC.

Related

Changing default compiler from clang to gnu gcc in termux

I want to set default compiler from clang to gcc in termux (android application).
gcc isn't available in official repo so I used pointless community repo. But now I can't configure the termux to use gcc instead of clang.
usr/bin/ contain g++, gcc, gcc-8, g++8.
But gcc --version command shows default clang.
gcc-8 --version shows:
"CANNOT LINK EXECUTABLE "gcc-8" : library "libc++_shared.so" not found
linker: CANNOT LINK EXECUTABLE "gcc-8": library "libc++_shared.so" not found.
I had this problem as well. The question that is asked by #Andy J is unfortunately less than helpful because there is not even ldconfig in this environment and I saw on Reddit that one of the developers said it's not even needed. (I doubt they are correct but it's not needed to fix this problem.
Do:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PREFIX/lib
export PATH=$PATH:$PREFIX/lib
Then finally you should be able to use GCC version 8.0.
~/gccbuild $ gcc-8 --version gcc-8 (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for
copying conditions. There is NO
warranty; not even for MERCHANTABILITY or F
FITNESS FOR A PARTICULAR PURPOSE.
Personally I'm trying to install it so that I can compile GCC 12, wish me luck with that lol.

Optimal way to install clang locally when GCC is outdated

I need to use tools that depend on clang on a Unix machine I remote onto at work. Anything I install is locally installed onto ~/local. I do not have root permissions.
/usr is pretty outdated, with gcc being at version 4.4.7. clang requires gcc 4.7+
I read on linux from scratch that a gcc 6.1 installation requires 8.4 gb. This is not something I can do, because that's huge.
Can someone advise me on the best workaround to install up to date clang on my ~/local?
Please and thanks.
Edit:
Courtesy of Nishant, here is the short answer:
Set up a personal machine running the same linux distro and cross compile using gcc to your specific architecture. For me, I will run a Redhat 6.5 VM and compile using gcc an arm x64 binary. Thanks Nishant!
You can get pre-build binaries for Unix system from LLVM's release website: http://llvm.org/releases/
You can then put the binaries in any local folder you want and source it using the PATH variable, which can be done by modifying your ~/.bashrc file by appending:
export PATH=$PATH:<clang-binary-directory>
Now you will able to use clang from the command line terminal as if it was installed.
If you want to build from source only, you can get older source code of clang which will use gcc 4.4.7 and build it and then use clang to build clang. Or get the latest clang binary and use it to build latest clang.

version `GLIBC_2.11' not found while using gcc

I have problem using gcc/g++ after I changed the machine I use,
I installed gcc-4.9.2 in my previous machine, when I moved to the new machine, I copied gcc folder to the new machine.
When I try to use I get this error :
/data/obenchek/gcc-4.9.2/bin/g++: /lib64/libc.so.6: version `GLIBC_2.11' not found (required by /data/obenchek/gcc-4.9.2/bin/g++)
I have already checked this question :
`GLIBC_2.11' not found
If it says right, the version of libc and g++ are not compatible , libc version :
/lib/libc.so.6
GNU C Library stable release version 2.4 (20090904), by Roland McGrath et al.
...
So I should reinstall gcc completely or there is a easier way to resolve this ??
I copied gcc folder to the new machine.
That's your problem: don't copy, install appropriate GCC package instead.
Most UNIX systems, including Linux, guarantee backward compatibility: a binary compiled on an older system continues to run on a newer one.
The reverse is not true: a binary compiled on a newer system often will not run on an older one. This is working "as designed".
In this particular instance, you copied GCC compiled with GLIBC-2.11 or newer to a machine that has GLIBC-2.10 or older. And that doesn't work.

How to install/update gcc-4.6 on openSUSE 11.2 (x86_64)?

I met an err when I installed JikesRVM, that is,
skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.4/libstdc++.so when searching for -lstdc++
So I am trying to install/update it to a later version. Now, the machine already has
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]
I am new to openSUSE, could you help?
Thanks!
You need to install 32 bit support for the GNU C/C++ compiler since JikesRVM on x86_64 currently supports only the 32 bit architecture.
To install this support in OpenSuSE 11.2 type
sudo zypper install gcc44-32bit gcc-32bit libstdc++44-devel-32bit
The first two provide runtime support for the C language and the 32-bit version of libgcc, the GCC low level runtime library. The third provides the 32-bit version of libstdc++, both the static import library and the dynamic library. It is the static libstdc++.a that was missing for JikesRVM.
To verify that the 32bit C++ build system is installed correctly you can test it with the following
echo "int main(){}" | g++ -x c++ -m32 -
Note Official support for OpenSuSE 11.2 has ended. Evergreen support will be available through 2013. Yet it is reasonable to update to 11.3 or a later version soon.

Compiling GHC 7.2+ on Linux with libc version < 2.7

I will like to install GHC 7.2.2 on a Redhat x86_64 (RHEL v5) server at work (in my user account. I don't have root access). I downloaded the generic binary for Linux x86_64 from GHC download page. But, when I run configure, it throws glibc version exception for ghc-pwd since the glibc version on Linux is 2.6. The required glibc version is 2.7.
I googled around but didn't find any pre-configured GHC binaries for Redhat 5. I will appreciate pointers on how to work around the glibc version issue if any one has figured it out for RHEL 5 (or any Linux flavor if the workaround is general). Alternatively, if there are zipped binaries for Redhat x86_64 available somewhere, I can download and unzip them, if you point me to them. Otherwise it looks like I am stuck with GHC 6.12 at work.
I built ghc 7.4.1 on stock RHEL 5.3, by starting with a binary build of ghc 6.6 or 6.8 (forget which one) which ran fine on the platform. Then I used that to build ghc 6.12 from source, and then used 6.12 to build 7.4.1 from source. Had to use gcc 4.3 to build 7.4.1, but that's fine as gcc 4.3 is available on RHEL 5.3.
It's not much work, just a fair amount of time for all the builds to complete.
I had a similar problem, so I compile ghc myself. Doing so is non-trivial because you need newer binutils and gcc. But t can be done (all in user-land).
GHC needs a GHC binary available to compile itself. There are precompiled GHC binaries available, but they have been built against newer glibc versions
RHEL 5 has glibc 2.5, so you can use GHC 6.8 and bootstrap from there. Generally GHC can be bootstrapped with $VERSION-2 or newer (the precise version is documented with the source downloads).
You will also need a newer version of gcc. #alex-iliev suggests that gcc 4.3 is sufficient, which is available on RHEL 5. Your alternative is to use Gentoo Prefix to install an up-to-date gcc.
Download and install the precompiled 6.8 in a directory:
wget http://www.haskell.org/ghc/dist/6.8.3/ghc-6.8.3-x86_64-unknown-linux.tar.bz2
bunzip2 ghc-6.8.3-x86_64-unknown-linux.tar.bz2
tar -xf ghc-6.8.3-x86_64-unknown-linux.tar
cd ghc-6.8.3
mkdir ~/ghc_bootstrap_6_8
./configure --prefix=/home/wilfred/ghc_bootstrap_6_8/
make install
Compile 6.12:
wget http://www.haskell.org/ghc/dist/6.12.3/ghc-6.12.3-src.tar.bz2
bunzip2 ghc-6.12.3-src.tar.bz2
tar -xf ghc-6.12.3-src.tar
cd ghc-6.12.3
mkdir ~/ghc_bootstrap_6_12
PATH=/home/wilfred/ghc_bootstrap_6_8/bin:$PATH ./configure --prefix=/home/wilfred/ghc_bootstrap_6_12/
make
make install
Compiling 7.2 and 7.6 is the same process as 6.12. Compiling can take several hours so you may want to look at quick builds (although you'll want a normal build for the final GHC version).
If you do go down the Gentoo Prefix root, just bootstrap your way to GHC 7.2. You can then modify $EPREFIX/usr/portage/eclass/ghc-package.eclass to add the line:
PATH=/home/wilfred/ghc_bootstrap_7_2/bin:$PATH
then simply add ghcbootstrap to your USE flags and:
emerge --nodeps ghc
Its ghc 6.8 to compile 6.12 from source

Resources