LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 10-26-2007, 11:20 AM   #1
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
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 ?

Thanks for any input and suggestions.
 
Old 10-26-2007, 11:55 AM   #2
Pratt
Member
 
Registered: Apr 2005
Location: Between Colombia and Germany
Distribution: Slackware Current
Posts: 78

Rep: Reputation: 15
You could try compiling with alien's Slackbuild
http://www.slackware.com/~alien/slackbuilds/gcc34/

Quote:
# -----------------------------------------------------------------------------
# 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
# -----------------------------------------------------------------------------
 
Old 10-26-2007, 12:36 PM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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:
Code:
#!/bin/sh
PATH=/usr/gcc-3.4.2/bin:$PATH
export PATH=/usr/gcc-3.4.2/lib/gcc-lib/i486-slackware-linux/3.4.2:$PATH
exec "$@"
Name it something like GCC342. Then to use it just type
'GCC342 make'
 
Old 10-26-2007, 12:49 PM   #4
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Thanks to all for the suggestions, I'll be trying this out right away I should check Alien Bob's repo more often, there are many useful packages there.
 
Old 10-26-2007, 01:34 PM   #5
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
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 ?
 
Old 10-27-2007, 01:34 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
Try using the wrapper like I do. It just makes the older version of gcc show up first in the path, so it shouldn't require any changes with cmake.
 
Old 10-27-2007, 05:16 AM   #7
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
The wrapper does not work. It keeps prompting me for another compiler as if it doesn't recognize it. I entered all the paths correctly for Alien Bob's version, it still won't work.
 
Old 10-27-2007, 09:13 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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.

Code:
#!/bin/bash
## src2pkg script for: 	cmake

SOURCE_NAME='cmake-2.4.6.tar.bz2'
NAME='cmake'
VERSION='2.4.6'
ARCH='i486'
BUILD='1'
PRE_FIX='opt/gcc-3.3.6'
# Any extra options go here
# EXTRA_CONFIGS=''
STD_FLAGS='-O2 -march=i486 -mtune=i686'

# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;

# do_all_processes can substitute these 16 steps:

pre_process
find_source
make_dirs
unpack_source
fix_source_perms

# configure_source
# compile_source

mkdir -p $SRC_DIR/cmake-build
cd $SRC_DIR/cmake-build
GCC336 ../bootstrap

CFLAGS="$STDFLAGS" \
CXXFLAGS="$STDFLAGS" \
../configure \
  --prefix=/opt/gcc-3.3.6 \
  --docdir=/doc/$NAME-$VERSION \
  --build=/opt/gcc-3.3.6

GCC336 make
GCC336 make install DESTDIR=$PKG_DIR

# fake_install
fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process
 
Old 10-27-2007, 10:24 AM   #9
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,913

Rep: Reputation: Disabled
gnashley:
Good information - thanks
 
Old 10-27-2007, 01:01 PM   #10
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
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.
 
Old 10-28-2007, 06:14 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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.

You can get the package or sources and scripts for gcc here:
http://distro.ibiblio.org/pub/linux/...vel/gcc-3.4.6/

And the sources, script and package for cmake are here:
http://distro.ibiblio.org/pub/linux/.../cmake-gcc346/

In the words of PatV -Have fun!
 
Old 10-28-2007, 06:25 AM   #12
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
With cmake you usually have to use 'cmake -i' and then say 'yes' for advanced options. Then you can change the install prefix, compiler, cflags, etc.

I'll try to get it working sometime soon. I'll report back if I get it working. (I'm not optimistic on this one)
 
Old 10-28-2007, 08:53 AM   #13
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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.
 
Old 10-30-2007, 04:38 AM   #14
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Original Poster
Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
I've finally had a chance to try this stuff out and it works perfectly ! Thank you very much gnashley. I owe you one
 
Old 11-18-2007, 02:13 AM   #15
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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:

PRE_FIX=/whatever
cmake . -DCMAKE_INSTALL_PREFIX=/${PRE_FIX}

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc versions compatibility with kernel versions.. mahesh_manthapuri Suse/Novell 1 03-22-2006 12:28 AM
Concurrent installation of mySQL & postgreSQL theNbomr Linux - Software 1 02-27-2006 02:31 PM
switching between gcc versions DrAMac Debian 2 08-30-2005 05:21 PM
multiple versions of gcc Avatar33 Linux - General 3 02-22-2005 02:06 PM
Can you have two different versions of gcc on the same system? the theorist Linux - Software 1 02-23-2004 04:53 PM


All times are GMT -5. The time now is 06:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration