My thoughts on Slackware, life and everything

What if gcc 7 gives you headaches?

In Slackware-current we use version 7.1.0 of the gcc compiler suite. These advanced compilers can sometimes be quite a bit more strict about what they accept as valid code. As a consequence, you will regularly run into compilation issues with software. Not just the software made with the scripts on, but also some of the software in the Slackware core distribution requires patches in order to get them to compile.

Until now, I have been lucky to find the patches I needed in the repositories of other distributions, or else developers patched their software themselves. But there will be corner cases where solutions and patches are not readily found, or the developers will simply not support gcc 7. Pale Moon is such a piece of software where the developers recommend compiling with gcc 4.x or as a last resort, gcc 5.

Also, the latest gcc compiler suite has dropped their Java compiler, it was no longer developed. So, no more gcc-java package. However if you want to bootstrap the OpenJDK compiler software, you need to start with a Java compiler. The openjdk developers recommend an already built OpenJDK package to compile a new release. But there may still be a case where you have to bootstrap that very first OpenJDK compiler.

So I took the old sources for gcc-5.4.0 which was part of Slackware-current for a while (11 August 2016 to 4 May 2017), and re-worked my gcc-multilib.SlackBuild script:

  • I renamed the package to “gcc5” so that it can be installed alongside Slackware’s gcc 7 packages
  • The binaries were given a suffix “-5” to make them stand apart from Slackware’s default compilers
  • All except the C, C++ and Java language compilers were removed
  • Only one all-encompassing package is built by the script
  • A profile script was added – you can ‘source’ it to activate the gcc-5 compilers as preferred compilers

The result is a gcc5-5.4.0 package – for Slackware-current, both 32bit and 64bit. Get them at .

The 64bit package is a multilib version, but you can install it without issues on a pure 64bit system. You will just not be able to compile 32bit programs with it.

How to use these compilers?

Simple: in your console or terminal, you ‘source’ the provided profile script, like this (there’s a c-shell compatible script as well):

source /etc/profile.d/

The command “source” is equivalent to the dot command ” . “. The profile script will (re-)define the common variables that are used by make and other programs to determine which binary to run as the compiler:

export CC=gcc-5
export CPP=cpp-5
export CXX=g++-5
export AR=gcc-ar-5
export NM=gcc-nm-5
export RANLIB=gcc-ranlib-5

So, all you have to do next is run your compile job as usual, in that same console or terminal. Nothing else needs to be done after sourcing the profile script. Your program will be compiled with the binaries provided by the gcc5 package.

I did limited testing:

  • With the above instructions, I ran my palemoon.SlackBuild script and it provided a package (whereas the gcc7 compiler in Slackware-current would cause the compilation to fail)
  • The provided gcj (GNU Java Compiler) was able to bootstrap the OpenJDK 7 sourcecode into a working binary package, which I could then use to compile OpenJDK 8 on slackware-current (OpenJDK 7 is the last release that can still be bootstrapped with the gcj compiler)

Hope this helps some people!



  1. chrisretusn

    Thanks a million Eric.

  2. Thomas Jett

    I’ve tried everything I can think of, and then some, to get the gcc5 compiler to work with no success. I’ve been trying to compile your restricted MPlayer first with the 7.x compiler; I got to one point and it failed, and I was able to hack the script and get it to go a little further, but it finally failed, and I could see nothing wrong with the script so I saw this article and tried with the 5.x compiler, but no matter what I do when I run the compiler it runs the 7.x version. I did note that when I try to whereis, find, locate the source command none of those commands turn up anything. BTW, I’m running a fresh install of Slackware current. Any help you could provide would be very welcome.

    PS: I did note that the script was not executable so I did a chmod +x on it and reran everything, but the 7.x compiler ran instead of the 5.x.

  3. alienbob

    Thomas, the /etc/profile.d/ is not executable for a reason. If it is executable, then it gets executed everytime you login and you would always have gcc5 as your preferred compiler. You do not want that.

    As to why it does not work for you… you are trying to find a program called “source” on your filesystem? You will fail, because “source” is a shell-builtin command.
    Did you actually type “source /etc/profile.d/” exactly like that, and pressed ENTER? Because it seems you did not. If you just run “/etc/profile.d/” then this command will run in a sub-shell and after executing, the subshell will terminate while your own shell was not modified. The “source” command takes a script file as argument, and executes that script in the CURRENT shell instead of a sub-shell.

  4. Thomas Jett


    Thanks for the quick reply. Yes I did run the script exactly as you described in the article source /etc/profile.d/ and hit enter after which I began compiling as usual with sudo ./MPlayer.SlackBuild. I spotted the compiler version in the output in the terminal, but let the build run till it failed. I also tried in follow up attempts just running the script as root from the very beginning after doing a sudo su and then running source /etc/profile.d/ after which I began compiling with the same result (actually I ran about every variation of sudo first before switching but switching to sudo su and then doing the same again). Since I don’t know every command possible I then began searching for the source command. When I couldn’t find it I then started checking everything I possibly could think of and that is when I discovered that the script wasn’t executable. I’ll change it back now that I know it’s not supposed to be, but still I have no clue as to why it won’t execute as its supposed to. If you would like, I’ll email you the compile logs if it will be of help. I didn’t past them in here since it would take up so much space. I’ll also attach the compile logs from my attempts to compile MPlayer before I read the article about the palemoon compile problems you had with the 7.x compiler and show you where I modified the script to get it to run a little further before it got to the point where I could not find a problem that I could fix. I’ve had problems with a couple of other SlackBuilds in your restricted builds failing, and I just thought it was because I was running current (this is the first time I’ve tried it, in the past I’ve always just used the current release).

    Thanks again!

  5. alienbob

    You can use a pastebin to post the compilation output. Also, please never use “sudo “, this is not Ubuntu where that kind of stuff might work. On Slackware it most definitely does not work the same as becoming full root. Your other command “sudo su” will also not give you a full root environment. Use either “sudo -i” or “su -“.
    You need to run “source /etc/profile.d/” in your root shell, immediately before you run that “./MPlayer.SlackBuild” command, as root.

  6. Thomas Jett

    OK, I’ll try that. A few years ago, I had a “friend” talk me into trying ubuntu, it was sometime after the Slackware 12.2 release, and I got in the habit of using sudo then. I used it for a couple of years, before I finally said enough! It reminded me so much of using windows after awhile that I refer to it now as winduhs lite 😉 I’ll have to create an account on pastbin as I’ve never had a need for it before, but I’ll do that today.

  7. Thomas Jett

    Ok, sorry for the delay getting this posted, but I figured that it would be more helpful to rerun the build again, and get the output you needed. Here is the output from the terminal at the beginning:
    bash-4.4$ su
    bash-4.4# source /etc/profile.d/
    bash-4.4# ./MPlayer.SlackBuild
    || MPlayer-20110624
    Extracting the source archive(s) for MPlayer…
    MPlayer-20110624/parser-mecmd.c. And, here is the url to the configure log where I posted it on pastbin: at least that should be it since I only signed up for a free account and the posts, they say, on free accounts are all public.

  8. alienbob

    Hi Thomas

    In the pastebin I only see the configure step, but the first line is indeed sufficient (Checking for gcc version … 7.1.0). In the source directory you will find a file “config.log” which will show you how configure determined that 7.1.0 was the compiler it must use. Also, the configure script itself contains the logic for the detection of the compiler, so you may want to inspect that script as well.

  9. alienbob

    What I do not understand though, is why you are compiling “MPlayer-20110624” on slackware-current. This is a source of 6 years old. Slackware-current itself contains version “1.3_20170208”. That is why I no longer update my own script.

  10. Matthew

    Hi there!

    Just wanted to say thank you 🙂

    I used your neat trick to setup gcc 7 alongside gcc 5 in slack 14.2. I\’ll probably do the same thing for gcc 6 and experimental gcc builds 🙂

    For anyone else doing the same – don\’t forget to set a path prefix when you configure GCC.

    Much appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 Alien Pastures

Theme by Anders NorenUp ↑