0

I am on Ubuntu Hardy Heron trying to compile gcc 4.4 from source. The problem is that I need MPFR version 2.3.2 or greater. I have MPFR version 2.3.1. I can verify this via running this small snippet of C code obtained from their site-:

#include <stdio.h>

#include <mpfr.h>

  int main (void)
  {
   printf ("MPFR library: %-12s\nMPFR header:  %s (based on %d.%d.%d)\n",
              mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
              MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
   return 0;
}

cc -o version version.c -lmpfr -lgmp

This prints out-:

MPFR library: 2.3.1       
MPFR header:  2.3.2 (based on 2.3.2)

I have downloaded and built MPFR(version 2.3.2) from source and it has installed correctly in /usr/local, but the problem is that gcc won't link to it by default. I have to use the following compilation options to link to my new MPFR library -:

gcc test_mpfr.o -o test_mpfr -Wl,-Bstatic -l:/usr/local/lib/libmpfr.a -Wl,-Bdynamic 

This produces the correct and expected output of -:

MPFR library: 2.3.2       
MPFR header:  2.3.2 (based on 2.3.2)

Now my questions is that

firstly how do I remove my default MPFR installation from my system (apt-get --purge remove libmpfr-dev does nothing), and

secondly how do I make my new MPFR installation my default one so that gcc can link to it automatically.

3 Answers 3

0

Removing the system gcc, mpfr is not a good idea. Please reinstall. (sudo apt-get install g++) And : You can have as many versions of gcc as you want, installed at the same time. The default compilers for Hardy : sudo apt-get install g++ g++-3.3 g++-3.4 g++-4.1 ,,, where g++ is the system compiler gcc/g++ version 4.2.4 .

Compilers, gcc44, g++44 are available for Ubuntu 8.04 Hardy, example i386 : {gcc44_4.4.7-2_i386.deb, gcc44-c++_4.4.7-2_i386.deb, libstdc++44-devel_4.4.7-2_i386.deb} . Links :

gcc44 https://drive.google.com/file/d/0B7S255p3kFXNYmpYeGZHS0RUR0U/view?usp=sharing gcc44-c++ https://drive.google.com/file/d/0B7S255p3kFXNMEF1NWFiVFViMlk/view?usp=sharing libstdc++44-dev https://drive.google.com/file/d/0B7S255p3kFXNWHB3ejd0TTNhUWc/view?usp=sharing

Install : Download the three packages, and ...

1) sudo apt-get install libgmp3c2
cd Downloads/
2) sudo gdebi gcc44_4.4.7-2_i386.deb
3) sudo gdebi libstdc++44-devel_4.4.7-2_i386.deb
4) sudo gdebi gcc44-c++_4.4.7-2_i386.deb

Note : Please advise, if your OS is amd64/x86_64, and 64bits packages can be uploaded.



If you really want to build gcc-4.4.7 manually : External mpfr, gmp is not required :

tar xvf gcc-4.4.7.tar.bz2 (A configured gcc cannot be reused, please start from scratch)
cd gcc-4.4.7/
tar xvf mpfr-2.4.2.tar.bz2
mv -v mpfr-2.4.2 mpfr
tar xvf gmp-5.0.0.tar.bz2
mv -v gmp-5.0.0 gmp

gcc requires a build folder outside the source ....

cd ../
mkdir build-gcc44
cd build-gcc44/
../gcc-4.4.7/configure --program-suffix=44 --prefix=/usr/local/gcc447 --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-multilib

make
sudo make install
cd /usr/bin/
sudo ln -s /usr/local/gcc447/bin/gcc44
sudo ln -s /usr/local/gcc447/bin/g++44

Using an extra compiler, examples :

1) export CC=gcc44 CXX=g++44 && [other command]
Like : 2) export CC=gcc44 CXX=g++44 && ./configure
3) gcc44 file.c

5
  • Are the packages that you have given part of the official Ubuntu distribution ? Because I did not find them on the Ubuntu site. How can I verify that they are un tampered ? also I tried downloading the gcc4.4 from here [mirrors.kernel.org/ubuntu/pool/main/g/gcc-4.4/…. But it didn't work since the dependencies are not met. Just tell me how I can install a more recent version of MPFR and have gcc link to that.
    – Kramer786
    May 30, 2016 at 15:03
  • MPFR is required for building gcc4.4 just download the gcc4.4.0 sources and check the perquisites.html file.
    – Kramer786
    May 30, 2016 at 15:10
  • My OS is x86_64
    – Kramer786
    May 30, 2016 at 15:11
  • OK, amd64 packages were created .... see my edited post ... May 30, 2016 at 21:18
  • Why can't a configured gcc be reused ? I don't understand. Could you please explain ?
    – Kramer786
    Jun 4, 2016 at 18:51
0

My OS is x86_64

Packages.amd64 : g++44_4.4.7-ubuntu8_amd64.deb, gcc44_4-4-7-ubuntu8_amd64.deb, libstdc++44-dev_4.4.7-ubuntu8_amd64.deb, created with $ dpkg-deb -b

Links : gcc44 https://drive.google.com/file/d/0B7S255p3kFXNQlVHeXdPc25sSEE/view?usp=sharing g++44 https://drive.google.com/file/d/0B7S255p3kFXNeU5jSG9ZdXNQQTQ/view?usp=sharing libstdc++44-dev https://drive.google.com/file/d/0B7S255p3kFXNbWxGNEM0TG93LW8/view?usp=sharing

1) sudo gdebi libstdc++44-dev_4.4.7-ubuntu8_amd64.deb
2) sudo gdebi gcc44_4-4-7-ubuntu8_amd64.deb
3) sudo gdebi g++44_4.4.7-ubuntu8_amd64.deb

The compilers were tested in Hardy with a ~150GB application, hundreds of c, c++ files : Result = OK.



MPFR is required for building gcc4.4

Of course. See my post. mpfr is unpacked inside gcc-4.4.7/.

How can I verify that they are un tampered ?

The many packages I have built over the years have been OK so far. No complaints from any users.

Today´s packages are handled with the Ubuntu Hardy´s alien command : Saves a few minutes. Instead of a real rebuild with ....

$ dpkg-deb -b packagename packagename_version_architecture.deb

The three converted packages are from the CentOS 5.11 repo http://mirror.centos.org/centos/5.11/os/i386/CentOS/ , i.e "Enterprise quality".


0

I had similar problem and want to remove old version of mpfr ( libmpfr4).

Solution

  • sudo apt-get remove libmpfr4
  • manually remove symlinks to old library from usr/local/lib

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .