On el8/el9/newer, how do you get newer versions of software like python3, gcc, java, etc? - linux

For example on el7:
to develop an nvidia CUDA application you need a newer gcc than the default gcc version 4.8.x and to get the newer version you would use a software repo called "Software Collections" (SCL)
the base python3 is 3.6 and you need newer python modules and so you install python3.8 from SCL
Starting on el8, and el9: the SCL is deprecated and so there is a different method for installing and configuring newer versions of gcc and python3.
On el8/el9/newer, how do you get newer versions of software like python3, gcc, java, etc?

in a nutshell, here are some examples for how to install and configure
for python3 to get python3.9: dnf install -y python39 && alternatives --set python3 $(command -v python3.9)
for gcc to get gcc-12: dnf install gcc-toolset-12 && source scl_source enable gcc-toolset-12
for java to get java-17: dnf install java-17 && bin_java_filename=$(rpm -qa|grep java-17|xargs rpm -ql|grep "bin\/java$"|head -1) && alternatives --set java ${bin_java_filename}
tested on rocky8, rocky9
which repo has the newer software versions?
the old method using "SCL" was deprecated
the new method is to use a repo called "appstream"
here is a post written by the distro maintainers explaining the change https://developers.redhat.com/blog/2018/11/15/rhel8-introducing-appstreams
the repo is enabled by default
how to: install newer software versions?
for python3: dnf install python39
for gcc: dnf install gcc-toolset-12
how to: change the system default?
for python3: alternatives --set python3 $(command -v python3.9)
for gcc:
edit your user .bashrc or .bash_profile or create a new file under /etc/profile.d/ with the following: source scl_source enable gcc-toolset-12
i thought scl_source would go away in el8, el9 but apparently not
for more info on scl_source go to this link https://unix.stackexchange.com/a/195219/5510 or Permanently enable RHEL scl
p.s. what is the difference between alternatives and update-alternatives?
the original tool is called update-alternatives and is from Debian linux distro
in EnterpriseLinux, Redhat rewrote the tool and called it alternatives and when you install alternatives the package also installs a symlink with name update-alternatives on your env var PATH to help you find the tool
the two are similar but not the same because their source code is different

Related

gobject-2.0-0 not able to load on macbook

I am facing this error when I start my flask application on Python3 and Mac OS:
OSError: cannot load library 'gobject-2.0-0': dlopen(gobject-2.0-0, 2): image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'
I am using weasyprint in my project which is causing this issue.
I tried to install glib and it is installed in my system.
I just managed the same issue on my Mac M1.
The problem was that symlinks to the libraries were not created (can't say should it be done by homebrew or weasyprint when installation).
So, I had to do it manually
sudo ln -s /opt/homebrew/opt/glib/lib/libgobject-2.0.0.dylib /usr/local/lib/gobject-2.0
sudo ln -s /opt/homebrew/opt/pango/lib/libpango-1.0.dylib /usr/local/lib/pango-1.0
sudo ln -s /opt/homebrew/opt/harfbuzz/lib/libharfbuzz.dylib /usr/local/lib/harfbuzz
sudo ln -s /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib /usr/local/lib/fontconfig-1
sudo ln -s /opt/homebrew/opt/pango/lib/libpangoft2-1.0.dylib /usr/local/lib/pangoft2-1.0
This solved the problem.
In order to TEST if Python can find the library you may run
from ctypes.util import find_library
find_library('gobject-2.0') # Pass any other lib name as an argument
UPD. There is no such problem if you install python with homebrew.
If you installed weasyprint package in your virtual env but did not installed some required packages for that, then that might be the reason. It was actually, in my case.
If you're mac user you need install pango and libffi, not to mention python as well.
Installation guide on mac
brew install python pango libffi
(venv) pip install weasyprint
To expand on the existing answers on Apple Silicon (M1) Macs:
If you have installed the packages with Homebrew and they are still not found or linked under /usr/local/lib, it is because they are installed on arm64 and found in /opt/homebrew/lib instead.
If you're using Python installed with Homebrew it should work without any extra work, however system Python and any managed Python versions (e.g. installed with Pyenv) will require some configuration.
1. Manual symlinking
Instead of linking each library individually to /usr/local/lib, you can link the /opt/homebrew/lib contents (as long as you don't have an existing /usr/local/lib directory):
sudo ln -s /opt/homebrew/lib /usr/local/lib
This will work as long as the library you're looking for is not from a keg-only formula (those will have to be linked individually).
2. Environment variables
A lot of answers point to setting some environment variable, like LDFLAGS or DYLD_LIBRARY_PATH to add search paths for libraries, but these will not work with Python based on my testing:
macOS comes with System Integrity Protection (SIP) which, among other things, sanitizes your environment variables in subprocesses, for example Python. Anything starting with LD or DYLD will be purged, so setting the environment variables in your terminal profile will not work.
You can Disable SIP to get these working, but Apple recommends only doing it temporarily when needed.
If you decide to go this route, here are a few options:
In Homebrew's Github discussions the question was answered by setting LDFLAGS:
export LDFLAGS=-L/opt/homebrew/lib
Similarly you could add the necessary paths to DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/opt/homebrew/lib
I had the same issue after the homebrew update. Turned out the issue was because of the older pango lib version.
I did brew install pango
This upgraded pango lib from 1.48.2 -> 1.50.4 which internally installed gobject's latest version as dep. And my issue got resolved.

How to install older gcc package using APT from a repository?

I have GCC v9. But I'm trying to install a GCC 4.8.1 version to test a library compilation on that very old version of GCC.
The version is not available in the official Ubuntu repos,it is deprecated, but I've found it in other mirrors as told by the official GCC website. This one seems like popular one:
https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
I have very little knowledge of linux package systems except for the basic. I want to keep both versions. So I should do this:
sudo apt -y install gcc-4.8.1 gcc-9
The reason why I want to use this command and not install it from the file, apart from the difficulty of doing that for me, is that I'm following a guide in order to have several GCCs on my system:
https://www.fosslinux.com/39386/how-to-install-multiple-versions-of-gcc-and-g-on-ubuntu-20-04.htm
When I add the url to the sources.list file seems like it is working.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update -q
But when I try to call the install with gcc-4.8.1 or gcc-4.8 , or even gcc-4 the package doesn't exist.
Package gcc-4.8 is not available, but is referred to by another
package. This may mean that the package is missing, has been
obsoleted, or is only available from another source E: Package
'gcc-4.8' has no installation candidate
Also, I don't know if websites like these can be added to the repos list in order to find the package using APT:
http://www.netgull.com/gcc/releases/gcc-4.8.1/
[EDIT]
I downloaded the package from the website I linked. I have no idea how to install this by hand. If only I could find a repository that could help me with this... I have no idea how to make APT help me with the installation.
But I'm trying to install a GCC 4.8.1 version to test a library compilation on that very old version of GCC.
Developers have tools up their sleeve so they don't have to install dependencies and bloating their systems for every library (and every configuration of that library!) they want to try out and test.
Use docker. You could write for example a testing script, assuming your project uses make:
# test_my_lib_in_gcc-4.8.sh
#!/bin/sh
docker run -ti --rm -v $PWD:/project -w /project gcc:4.8 -u $UID:$GID sh <<EOF
make && make test
EOF
that will compile and test your application in using 4.8 gcc. Consider how easy it is to change gcc version - just change the number. You could test your library in gcc, in different versions, and using other compilers and on different distributions to make sure it works for others. If you're a developer of the library, write an automatized CI pipeline that would automatically test your application each commit in specific docker environment, using ex. https://docs.gitlab.com/ee/ci/README.html or https://travis-ci.org/ .

objdump is missing from windows10 pro (msys2 installed)

I have installed msys2 using chocolatey.
I have tried msys2-installer module from chocolatey too.
But I can not find objdump on my system. Should I install something more ?
MSYS2 supports three different compiler toolchains, all with their own objdump utility. I'm not sure which one you want to use, but you can just install them all by running:
sudo pacman -S binutils mingw-w64-x86_64-binutils mingw-w64-i686-binutils

Dart throwing errors on linux: GLIBC_2.14 GLIBC_2.15 not found

I'm running Debian 7.2 on Google Compute Engine (Though I suspect Centos, Red Hat, and Amazon Linux AMI all have the same problem). After downloading the 64-bit Linux version of the Dart SDK from this page, any dart command I run, for example, dart --version, will output the following error:
./editor/dart/dart-sdk/bin/dart: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.15' not found (required by ./editor/dart/dart-sdk/bin/dart)
./editor/dart/dart-sdk/bin/dart: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./editor/dart/dart-sdk/bin/dart)
Update: October 2014: Dart can now be installed on Debian with apt-get:
Instructions summarized from the dart website:
# Enable HTTPS for apt.
sudo apt-get update
sudo apt-get install apt-transport-https
# Get the Google Linux package signing key.
sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
# Set up the location of the stable repository.
sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
sudo apt-get update
# Finally, install the dart package!
sudo apt-get install dart
Instructions for building the binary yourself:
This problem appears to be caused by Google compiling against an edge version of GLIBC (>= 2.15) which is not generally supported on Linux outside of Ubuntu 12 (Precise Pangolin).
First of all, do not attempt to download an experimental version of GLIBC or EGLIBC. I was able to get dart to work using that method, but the rest of my machine fell apart. Updating GLIBC is a recipe for madness.
Instead, the best solution is building dart from source. Despite the GLIBC version requirements of the binary, the source itself has no such requirements. There are wiki pages for installing from source on debian, centos/fedora/red hat/amazon, ubuntu, and other linux versions.
Here is an overview of those steps, which I can confirm works on Debian 7.2. The centos/fedora/redhat steps appear to be the same except they use yum instead of apt-get.
Install subversion and the required build tools:
sudo apt-get -y update
sudo apt-get -y install subversion
sudo apt-get -y install make
sudo apt-get -y install g++
sudo apt-get -y install openjdk-6-jdk
Check out google's depot tools and add gclient to your path
svn co http://src.chromium.org/svn/trunk/tools/depot_tools
export PATH=$PATH:`pwd`/depot_tools
Download the dart source at the desired branch.
Replace 1.2 with whatever branch you wish to build. You can see a list of available versions here. In general, the latest numbered branch is best.
gclient config http://dart.googlecode.com/svn/branches/1.2/deps/all.deps
gclient sync
gclient runhooks
Move into the new dart directory
cd dart
Do only A or B below:
Note: For 32bit, use the --arch=ia32 flag instead.
A. Build the entire Dart SDK including pub, dart2js, dart, etc.:
tools/build.py --mode=release --arch=x64 create_sdk
B. Build just the dart executable:
tools/build.py --mode=release --arch=x64 runtime
The dart executable is now at either out/ReleaseX64/dart or out/ReleaseX64/dart-sdk/bin/dart you can do a smoke test by printing the version
dart/out/ReleaseX64/dart --version
The output should be something like Dart VM version: 1.2.0 (Mon Mar 3 03:06:20 2014) on "linux_x64".
How to help fix this issue
This was much more painful than it needed to be, since the binary clearly doesn't need to be built using GLIBC >= 2.15. If you wish to draw attention to this issue, please star this dart bug.

System crash after oracle installation with yum

recently i tried to install oracle on my linux with apt (I never used yum before) using fast manual:
http://www.oracle.com/technetwork/articles/servers-storage-admin/ginnydbinstallonlinux-488779.html
And after command:
sudo yum install oracle-rdbms-server-11gR2-preinstall
I got error:
Failed: ca-certificates.noarch 0:2010.63-3.el6_1.5 chkconfig.x86_64 0:1.3.49.3-2.el6 file-libs.x86_64 0:5.04-15.el6 filesystem.x86_64 0:2.4.30-3.el6
initscripts.x86_64 0:9.03.38-1.0.1.el6_4.2
Complete!
And something gone wrong because command like: ps, top are crashing
login#Ass-K55VJ:/etc/yum/repos.d$ ps -e
ps: relocation error: ps: symbol procps_number_version, version _3_2_5 not defined in file libproc-3.2.8.so with link time reference
login#Ass-K55VJ:/etc/yum/repos.d$ top
Segmentation fault (core dumped)
then I tryied to uninstall oracle and dependencies but after command:
sudo yum remove oracle-rdbms-server-11gR2-preinstall
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.6 (r266:84292, Jul 10 2013, 06:42:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If you cannot solve this problem yourself, please go to the yum faq at: http://wiki.linux.duke.edu/YumFaq
So it seems like yum install in my system new libraries but didn't link it correctly? I dont know what do in this moment because it seems like armagedon on my ubuntu...
Does this mean you're on ubuntu and tried to install rpm packages using yum? The manual you used is for Oracle Linux 6, why would you try that on ubuntu?
rpm packages are not compatible with debian based systems like ubuntu, which use deb packages. So you've probably screwed your system big time, overwriting important system libraries with incompatible ones.
If apt-get is still working, then you can try to reinstall (apt-get --reinstall install) the equivalent libraries to the ones mentioned in the install manual you linked to - naming isn't always the same for rpm and deb packages. dpkg -l should help you see which the correct installed libraries are. I'd start with the C libraries (libc) etc.
But if apt-get is screwed also, then you'd need to download the packages manually from an ubuntu mirror and install them using dpkg, but I think a reinstall (or restore from backup if you have one) would be the best option.

Resources