Using GCC10 with Qt on KDE Neon 18 - gcc

I would like to play around with some very new C++20 features. Some of them are supported by GCC10 only. Unfortunately the most current release is GCC9.3 so I need to use the unreleased version of GCC10.
I did the following to install it:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install gcc-10 g++-10
This worked fine. However I am unable to make it the default compiler. As usual I tried:
sudo update-alternatives --config gcc
This says there would be no alternatives. Why?

You can do it manually:
cd /usr/local/bin
sudo ln -s /usr/bin/gcc-10 gcc
sudo ln -s /usr/bin/g++-10 g++
Then open a new terminal windows and gcc should refers to gcc-10. It should work for simple cases. If it does not, you will have to create all the appropriate symbolic links for all GCC 10 ecutables and libraries...
I think the best option is to compile yourself GCC 10 and install it in your home directory. This is what I do on my minimalist Gentoo installation, I suppose it will work too on Ubuntu:
mkdir ~/src
cd ~/src
git clone https://github.com/gcc-mirror/gcc.git
mkdir gcc_build
cd gcc_build
../gcc/configure --enable-libsanitizer --prefix=~/usr --with-gcc-major-version-only --disable-bootstrap --enable-language=c,c++,lto
make -j16
make install -j16
Compilation may last about 10 minutes. Consider to adapt the -j16 option to your machine: this is the number of jobs launched simultaneously by make. Using twice the number of parallel thread supported by your CPU is a good choice. Then add appropriate environment variables to your ~/.bashrc file:
export LD_LIBRARY_PATH=~/usr/lib64:~/usr/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=~/usr/lib64:~/usr/lib:$LIBRARY_PATH
export LD_RUN_PATH=~/usr/lib64:~/usr/lib:$LD_RUN_PATH
export PATH=~/usr/bin:$PATH
When you do not want to use gcc-10 any more comment out these lines and open a new terminal.

Related

Installing gfortran without administrator's permission

I want to install kaldi on the server, when I run the check_dependencies.sh, it tells me that I should install gfortran, but I'm not allowed to use sudo.
I have tried to install gfortran from anaconda, but it only shows that gfortran is not available from current channels, even though I had updated my conda.
Is there any alternative way? thanks!!
You can easily install GCC in your home directory without any root or admin rights.
Just download the source (e.g. a snapshot of your choice), run the provided ./contrib/download_prerequisites and than the holy trio configure --prefix=$HOME --enable-languages=c,c++,fortran, make, make install.
I recommend running these in a different directory. In general, just follow https://gcc.gnu.org/wiki/InstallingGCC A full example of a possible sequence of commands is at the bottom of the page.
I typically use the conda-forge::compilers package for my compilation needs. It includes C, C++, and FORTRAN, and abstracts over the platform (i.e., provides equivalent compilers for osx-64, linux-64, etc.).
In this particular case, the following environment appears sufficient to compile Kaldi:
kaldi-compile.yaml
name: kaldi-compile
channels:
- conda-forge
dependencies:
- compilers # this covers C, C++, and FORTRAN
- make
- cmake
- icu
- openblas # `mkl` could be used instead
Tested this works in the Mambaforge container:
docker run --rm -it condaforge/mambaforge bash
With:
Docker Session
## create env
mamba create -yn kaldi-compile compilers make cmake icu openblas
## activate env
conda activate kaldi-compile
## basic install instructions
cd /home
git clone https://github.com/kaldi-asr/kaldi.git kaldi --origin upstream
mkdir -p kaldi/build && cd kaldi/build
## configure, build, install
cmake -DCMAKE_INSTALL_PREFIX=../dist ..
cmake --build . --target install -- -j8

Linphone compiling problems on osx

I'm trying to compile linphone on mountain lion. I have downloaded the sources and followed all the instructions in the README.macos file. The first time, when I got to '$ port install ige-mac-integration' an error occurred. It said gtk2 had to be installed with x11, however, the instructions said to install it with quartz and no_x11. I tried installing gtk2 again, this time with x11, but when I get to the compiling process it tells me quartz is needed. I can't install both, because the gtk2 installation will complain about it, and it seems I need both to complete the entire process of installing and compiling linphone.
I have tried these steps with the downloadable sources, as well as the git sources, both gave me the same problems. Linphone does not have a forum, so I couldn't ask it on their site.
I just need to get the sources and start using them, so any recommendations on how to open the linphone source, edit it, and compile/run it would be very welcome. The ideal situation would be where I can just open an xcode project file.
This is the readme file:
**********************************
* Compiling linphone on macos X *
**********************************
You need:
- Xcode (download from apple or using appstore application)
- Macports: http://www.macports.org/
Download and install macports using its user friendly installer.
- Install build time dependencies
$ port install automake autoconf libtool intltool
- Install some linphone dependencies with macports
$ port install speex
$ port install libosip2 # WARNING: currently outdated in macport
$ port install libeXosip2 #WARNING: currently outdated in macport
$ port install ffmpeg-devel
$ port install libvpx
- Install srtp (optional) for call encryption
$ port install srtp
If that fails, get from source:
$ git clone git://git.linphone.org/srtp.git
$ cd srtp && autoconf && ./configure --prefix=/opt/local && make libsrtp.a
$ sudo make install
- Install zrtpcpp (optional), for unbreakable call encryption
$ port install cmake
$ git clone git://git.linphone.org/zrtpcpp.git
$ cd zrtpcpp && cmake -Denable_ccrtp=false . && make
$ sudo make install
- Install gtk. It is recommended to use the quartz backend for better integration.
$ port install gtk2 +quartz +no_x11
$ port install hicolor-icon-theme
- Compile and install the tunnelsu
If you got the source code from git, run ./autogen.sh first
Then or otherwise, do:
$ ./configure --prefix=/opt/local && make && sudo make install
- Compile linphone
If you got the source code from git, run ./autogen.sh first.
Then or otherwise, do:
$ ./configure --prefix=/opt/local --with-readline=/opt/local --disable-strict --disable-x11 --with-srtp=/opt/local --with-gsm=/opt/local --enable-zrtp && make
Install to /opt/local
$ sudo make install
Done.
If you want to generate a portable bundle, then install gtk-mac-bundler.
Use git:
$ git clone https://github.com/jralls/gtk-mac-bundler.git
$ cd gtk-mac-bundler && make install
$ export PATH=$PATH:~/.local/bin
#make this dummy charset.alias file for the bundler to be happy:
$ sudo touch touch /opt/local/lib/charset.alias
Then run, inside linphone source tree:
1. Run configure as told before but with "--enable-relativeprefix" appended.
$ make
$ make bundle
The resulting bundle is located in linphone build directory, together with a zipped version.
For a better appearance, you can install the gtk-quartz-engine (a gtk theme) that make gtk application more similar to other mac applications (but not perfect).
$ git clone https://github.com/jralls/gtk-quartz-engine.git
$ cd gtk-quartz-engine
$ autoreconf -i
$ ./configure --prefix=/opt/local && make
$ sudo make install
Generate a new bundle to have it included.
Below is the details to configure the dependencies and build linphone.
==============================================================
Step: 1:- Dependency configuration:
I just followed the instruction which is available in "README.macos" upto sqlite3 configuration. I had some problem with dependancies configuration.
Because of macport version, srtp configuration is failed. So I have downloaded "MacPorts-2.1.3-10.8-MountainLion.pkg" and installed manually.
Because of GTK version, libsoup is failed. So I have downloaded "GTK_2.18.5-X11.pkg" and installed manually.
After the manual installation, I have followed "README.macos" again for reconfiguration.
NOTE: Sometime terminal won't recognize "wget".
--> Solution: just execute below command.
echo 'alias wget="curl -O"' >> ~/.bash_profile
Step: 2:- Compile and Install:
I got some problem related to intltool while compiling.
Solution: just I set the path by executing below commands
export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info
Now it is successfully compiled and installed.
Step: 3:- Creating bundle to run the app:
Just I followed below commands to make the build.
If you want to generate a portable bundle, then install gtk-mac-bundler.
Use git:
$ git clone https://github.com/jralls/gtk-mac-bundler.git
$ cd gtk-mac-bundler && make install
$ export PATH=$PATH:~/.local/bin
#make this dummy charset.alias file for the bundler to be happy:
$ sudo touch touch /opt/local/lib/charset.alias
Then run, inside linphone source tree:
1. Run configure as told before but with "--enable-relativeprefix" appended.
$ make
$ make bundle
It will create "linphone.app" file in current linphone directory. It will support only for "Mountain Lion".
Step: 4:- Support for lower version: (e.g.: Lion, Snow Leopard...)
We have to configure "libiconv hack" to supporting for lower version
I think it will help you.
I wrote an answer here. It's a bit long but I sincerely hope it is clear enough and will help you.
It contains the build settings and other libs you need to include.
Cool stuff I didn't need to run the make :)
Best,

How to use pip install where one requirement has dependency on version on gcc-4.5

I am installing an egg packaged for pip, inside my virtualenv, under Python 2.7.2.
The egg has 16 requirements, one of which (pycryptopp 0.5.29) is known to fail with gcc-4.6 and hence must be compiled with 4.5. The system has both gcc-4.6 (default) and gcc-4.5 installed.
How do I configure/hack pip install to build this package specially? (or do I just temporarily kludge the link /usr/bin/gcc while installing this package)
Do I need to clean up the existing (virtualenv)/build directory where it broke, and if so how?
(I already read the pip documentation and searched SO + SU)
No need to fiddle around with symlinks here. On most Linux systems you can set the compiler to use with the CC env var. In case of pycryptopp and pip the following might help:
$ CC=/usr/bin/gcc-4.5 pip install pycryptopp
given that you have GCC 4.5 installed in that location. This worked fine for me on Ubuntu 11.10 (oneiric) with packages gcc-4.5 and g++-4.5 installed.
(I retitled the question from "How to use pip install where one requirement must be compiled with gcc-4.5?")
1) The correct method is to build with "--disable-embedded-cryptopp" which links to libcryptopp. Some people report runtime issue but It Works For Me.
pip install --install-option="--disable-embedded-cryptopp" pycryptopp
2.) A truly ugly workaround which I used (and which ulif helpfully points out can be obviated by using CC=.. ) is to invoke pip install specifically for the problem package, and temporarily kludge the link to gcc.
pushd /usr/bin; sudo rm gcc-4.6; ln -s gcc-4.5 gcc; popd;
pip install pycryptopp
pushd /usr/bin; sudo rm gcc-4.5; ln -s gcc-4.6 gcc; popd;
Further reasons this is bad: it requires root access and messing with the link to gcc binary. It certainly can't be Makefile'd.
Adding this for completeness to extend upon the existing good answers; if you are on apt based distribution such as Ubuntu or Debian, you can do the following:
Step 1: Install the versions of gcc/g++ you need
sudo apt install gcc-7 gcc-8 g++-7 g++-8
Step2: Install your gcc/g++ versions into "alternatives" system of your OS:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
Step 3: Select your active gcc/g++ versions
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
It will in each case ask you which version you want, or use the "weight" you provided to select automatically for you:
Selection path Priority Status
--------------------------------------------------------------------
* 0 /usr/bin/gcc-8 80 auto mode
1 /usr/bin/gcc-8 80 manual mode
2 /usr/bin/gcc-7 70 manual mode
Press ENTER to maintain, or type the selection number to the corresponding version.
TIP: If you want to delete a version, simply use this:
sudo update-alternatives --remove gcc /usr/bin/gcc-7
You will still use root/sudo access to do this, but it is much cleaner than dealing with manually deleting/creating links, or specifying environment variables on the commandline. It is the recommended way of selecting versions for all kinds of things in arpt based distributions.

Need help in compiling lighttpd on MacOSx

I try download lighttpd 1.4.23 source, and compile it on MacOSX 10.5.5.
This is the error I am getting:
$ ./autogen.sh
./autogen.sh: running `libtoolize --copy --force'
./autogen.sh: line 19: libtoolize: command not found
I tried ask the same question on lighttpd forum, but I can't get any help there.
Thanks in advance.
libtoolize is part of GNU libtool, a package for building libraries portably. On the Mac, one option for getting it is to use MacPorts, a package manager which works in a similar fashion as Gentoo and FreeBSD, in that it compiles packages on your machine. See http://www.macports.org/install.php.
Beware, though, that it will be installed as glibtoolize, i.e. with a 'g' prefixed. That is a standard way to make GNU tools live in parallel with UNIX tools of the same name, that might be present (even though there isn't one in this particular case).
The command for installing libtool from MacPorts is: sudo port install libtool
Add a '-d' flag after the 'port' command to see the build output.
Here's what I use to install lighttpd 1.4.25 on Mac OS X 10.6.2. If I remember correctly, the same thing worked for me in a recent version of Mac OS X 10.5.
Install Xcode Developer Tools
Either install them from the DVD that came with your Mac (under Optional Installs) or download them from Apple's developer page.
Install PCRE
curl -O http://softlayer.dl.sourceforge.net/project/pcre/pcre/7.9/pcre-7.9.tar.gz
tar xzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && sudo make install
cd ../
Install lighttpd
curl -O http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.25.tar.gz
tar xzf lighttpd-*.tar.gz
cd lighttpd-*
./configure
make && sudo make install
Note that the URLs above will quickly go out of date; you may need to download the latest versions of the .tar.gz packages from a different location.

How to compile Clisp 2.46?

When I try to compile the newest version of Clisp on Ubuntu 8.04 I always get this error after running configure:
Configure findings:
FFI: no (user requested: default)
readline: yes (user requested: yes)
libsigsegv: no, consider installing GNU libsigsegv
./configure: libsigsegv was not detected, thus some features, such as
generational garbage collection and
stack overflow detection in interpreted Lisp code
cannot be provided.
Please do this:
mkdir tools; cd tools; prefix=`pwd`/i686-pc-linux-gnu
wget http://ftp.gnu.org/pub/gnu/libsigsegv/libsigsegv-2.5.tar.gz
tar xfz libsigsegv-2.5.tar.gz
cd libsigsegv-2.5
./configure --prefix=${prefix} && make && make check && make install
cd ../..
./configure --with-libsigsegv-prefix=${prefix} --with-readline --with-unicode --with-module=i18n --with-module=gdbm --with-module=pcre --with-module=readline --with-module=regexp
If you insist on building without libsigsegv, please pass
--ignore-absence-of-libsigsegv
to this script:
./configure --ignore-absence-of-libsigsegv --with-readline --with-unicode --with-module=i18n --with-module=gdbm --with-module=pcre --with-module=readline --with-module=regexp
I've tried doing as requested, but it didn't help: it seems to ignore the --with-libsigsegv-prefix option. I also tried putting installing libsigsegv in a standard location (/usr/local). Oh, and of course, Ubuntu tells me that libsigsegv and libsigsegv-dev are installed in the system.
I'd really like to be able to compile this version of Clips, as it introduces some serious improvements over the version shipped with Ubuntu (I'd also like to have PCRE).
Here are my notes from compiling CLISP on Ubuntu in the past, hope this helps:
sudo apt-get install libsigsegv-dev libreadline5-dev
# as of 7.10, Ubuntu's libffcall1-dev is broken and I had to get it from CVS
# and make sure CLISP didn't use Ubuntu's version.
sudo apt-get remove libffcall1-dev libffcall1
cvs -z3 -d:pserver:anonymous#cvs.sv.gnu.org:/sources/libffcall co -P ffcall
cd ffcall; ./configure; make
sudo make install
cvs -z3 -d:pserver:anonymous#clisp.cvs.sourceforge.net:/cvsroot/clisp co -P clisp
cd clisp
./configure --with-libffcall-prefix=/usr/local --prefix=/home/luis/Software
ulimit -s 16384
cd src; make install
If you look at 'config.log' it might tell you why configure is not finding libsigsegv

Resources