How do I sanely install & keep 2 concurrent versions of gcc ?
SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How do I sanely install & keep 2 concurrent versions of gcc ?
I'm having problems with the gcc-4.1.2 that comes with Slackware 12.0. Many things don't like to compile and need patches or tricks to make them compile and even then they barely work properly. I want to install a gcc-3.x version concurrently with the current version, but I want to do it sanely so they don't conflict and screw up my system. Is this possible ? Is it really as easy as compiling and installing gcc to /usr/local ? What kind of problems would I run into, if any ? Has anyone successfully done this ?
# This is a gcc34 compatibility SlackBuild for use in Slackware > 11.0 ,
# where gcc4 is the default compiler suite.
# This gcc34 build installs to /usr/gcc34 and will not interfere with gcc4.
# *** Use gcc34 in your scripts, as follows ***
# * By using environment variables:
# Most softwares support the CC and CXX environment variables.
# First assign them, then run configure and/or make. Example:
# CC=gcc34 CXX=g++34 ./configure
# * Using configure support:
# If the software is using the standard GNU automake and configure,
# then there is a chance it supports other compilers by passing in
# a setting to the configure script.
# First run configure --help to see if it mentions anything.
# The following example is from MPlayer:
# ./configure --help
# ./configure --cc=gcc34
I do something similar to what AlienBob does except that I create a small wrapper for each version to setup the PATH. In other words, you just need to configure and install the alternate version in a separate path (like /opt/gcc-3.4.2 or /usr/gcc-3.4.2) and then create a small script with lines like this:
I installed Alien Bob's package and tried exporting new paths but it won't work with cmake. I tried using 'cmake -i' for interactive mode and setting all the settings there, but it won't let me select the older version of gcc. What else must I do to get it to work with cmake ?
Okay, I hadn't ever installed or tried to use cmake -the only thing I had run into that needed it was cdrkit and just decided to not use that.
Anyway, I downloaded the cmake package for slack-12 and tried to run it on my slack-11 box -it promptly complained about not finding CXXLIBS_3.4.5 so I could see already that it wasn't going to be a snap.
So, I downloaded the sources and started looking at the compile method, etc. Turns out that cmake gets built for specific compiler and library versions. So, you'll have to configure and re-compile cmake to use your alternate compiler. By installing it in the same place as your alternate compiler you'll be able to use a single wrapper to set up the path for both gcc and cmake.
I've built it using src2pkg (of course!), but most of it is using manually scripted lines, so I'll guess that seeing it will be of use to you when you compare it to PatV's SlackBuild for cmake.
The important things are to get the --prefix and --build to match your alternate compiler. Notice that I've used the alternate compiler to compile cmake, but that may not be necessary. You could also set the CC variable instead. If your alternate compiler is using a program prefix then you could probably install everything in the regular path. I just find it lots easier to use a wrapper and keep everything in a separate directory. (My gcc-3.3.6 is in /opt/gcc-3.3.6)
This should at least help to get you on your way.
## src2pkg script for: cmake
# Any extra options go here
STD_FLAGS='-O2 -march=i486 -mtune=i686'
# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;
# do_all_processes can substitute these 16 steps:
mkdir -p $SRC_DIR/cmake-build
GCC336 make install DESTDIR=$PKG_DIR
Well, I just tried re-compiling cmake with the new compiler and settings, and it did compile. BUT, it still refuses to accept the gcc34 compiler as an option, even tho it itself was compiled with this compiler.
Am I missing something ?
I hate cmake, I've hated it since the first time I've had to use it. Usually if a program uses cmake, I just delete it promptly and look for something else. I know, it's a bad attitude to have, but I really hate it. It's so incredibly cumbersome and unintuitive to use. I also hate jam All other build systems are fine ... scons, gmake, etc.
I'll join you in hating cmake -even after getting it working on the first re-compile. I started over, though in order to compile it under ym minimal Slack-12.0 install so that you can just download the packages if you like.
As I mentioned it may be possible to get this to work using AlienBobs' method of installing an alternate comnpiler if you set CC and CXX before running bootstrap. But I'm far from sure of that and I believe that the way I do it is easier and more dependable -I have 5 compiler installed on my system and never have any problems, nor do I have to edit and .bashrc files, etc.
If you have src2pkg installled you can easily re-compile both gcc-3.4.6 and cmake using my scripts. Or you can cut the guts out and paste them into the middle of a SlackBuild and use them that way.
First build the alternate gcc-3.4.6 compiler -the script installs the wrapper for you. Only then build cmake as the srcpkg build script calls the GCC346 wrapper to compile cmake. I've up-dated these so that they install under /usr/gcc-3.4.6 instead of /opt/gcc-3.4.6 since that seems to be the way others prefer to do it.
If you go the SlackBuild route be sure to pay attention to the --prefix and --build options. The alternate cmake installs to the same directory as the laternate compiler so that usage is transparent. To build sources which require cmake with the gcc-3.4.6 compiler just unpack, cd in there and run 'GCC346 make'.
One thing I see that makes me hate cmake even more is that it compiles everything to install under /usr/local, so if you find out how to change that I'd appreciate knowing about it.
so, you should be able to run it like this:
'GCC346 cmake -i', or create a separate wrapper for cmake with the same contents as the one for the laternate gcc. Thanks for the tip.
I'm pretty sure you'll have no trouble getting it to work my way. Using separate directories for the alternate compiler has the advantage over using a renamed gcc because many Makefiles explicitly set CC = cc or CC = gcc, and unlsess you edit the Makefile it will always use that.
Also, note that the packages are named with a different name than the regular versions so that pkgtools doesn't get confused and try to upgrade, instead of letting you have both programs installed.
If you don't feel like messing with re-compiling gcc and cmake, just install my packages and be done with it. I have checked them out both times by compiling cdrkit which goes pretty fast, except you also need libcap installed for it to compile.
I first worked this out on my regular slack-11.0 box using gcc-3.3.6 as the alternate compiler, but the directories I ointed you to have the gcc-3.4.6 versions compiled under slack-12.0.
H_TeXMeX_H, you may be interested that I've added support for cmake to my src2pkg program. It took me a while to figure out how to get it to use a non-deafult PREFIX instead of /usr/local without using interactive mode:
After doing that using the regular 'make' && 'make install' seems to do the trick. Since you have been fooling with cmake using a cmake which is not in the normal path you'll need to adjust for that. I also did my experiments with a cmake which is not in the regulra path -I had compiled a version for use with gcc-3.3.6. I was then trying it out trying to get it all to work seamlessly with src2pkg. I used to write srcpkg scripts which included MAKE_COMMAND='GCC336 make'. But during the course of looking at cmake, I found that it works fine to call src2pkg using the gcc wrapper:
'GCC336 src2pkg tarball-name'
Of course that will use the cmake which is installed where the compiler is also, if needed.