Compile gcc-4.1.2 on Ubuntu 12.04 64bit (maya plugins development)

Hi all, i just managed for the first time to compile the proper gcc version (4.1.2) for maya on ubuntu.
I’ll try to be as clear as possible but if any problem occurs feel free to write a comment! I obvioulsy expect that the questions are quite techincal and i also expect that you know at least how to move on linux.

First of all you ave to download the proper gcc version from . I choosed the tar.gz version and my guide refers to that one.
Create a folder where to build the gcc version

mkdir ~/gcc412

Extract the downloaded gcc release to that folder

tar -C ~/gcc412/ -xzvf /path/to/the/file/gcc-4.1.2.tar.gz

Make a build folder:

mkdir ~/gcc412/gcc-build/

At this stage we should be ready to build but first we need to be sure that we’ve got all the dependencies needed to compile. We need the linux-headers gcc-multilib, zlib1g, zlib1g-dev, zlibc

sudo apt-get install linux-headers-$(uname -r) gcc-multilib zlib1g zlib1g-dev zlibc

Then we need also to fix some file in the gcc folder.

First of all you need to edit the file ~/gcc412/gcc-4.1.2/gcc/config/i386/t-linux64.

At line 9 you should find:

MULTILIB_OSDIRNAMES = ../lib64 ../lib

You need to modify it as follows:

MULTILIB_OSDIRNAMES = ../lib64 ../lib32

Open the file ~/gcc412/gcc-4.1.2/libstdc++-v3/configure and at line 8284 replace:

sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`

with:

sed -e 's/GNU ld (GNU Binutils for Ubuntu) \([0-9.][0-9.]*\).*/\1/'`

Than we need to edit another file (Thanks Karl!!). Open the file ~/gcc412/gcc-4.1.2/gcc/config/i386/linux-unwind.h:


Line 139:
from: struct siginfo *pinfo;
to: siginfo_t *pinfo;
Line 141:
from: struct siginfo info;
to: siginfo_t info;

Another thing to do is to link some library otherwise the compiler won’t find it.

cd /usr/lib
sudo ln -s x86_64-linux-gnu/crt1.o crt1.o
sudo ln -s x86_64-linux-gnu/crti.o crti.o
sudo ln -s x86_64-linux-gnu/crtn.o crtn.o

At this point we are ready to compile gcc.

Go in the build folder:

cd ~/gcc412/gcc-build

run the configure as autodesk suggests:

../gcc-4.1.2/configure --prefix=/opt/gcc412 --program-suffix=412 --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --disable-libunwind-exceptions --enable-__cxa_atexit --enable-languages=c,c++

and then compile it:

make -j 2 bootstrap MAKEINFO=makeinfo

As soon as the compiling process ends without throwing errors you will be able to run:

sudo make install

Then we may decide to link it:

sudo ln -s /opt/gcc412/bin/gcc412 /usr/bin/gcc412

12 Responses

  1. Hi Cheers for the info. Do you know if this needs to be done for version 12.10? Also I am noticing a lot of crashes with plugins that were compiled with GCC 4.1.2, would this help make them run by this technique?

  2. Hi, thanks for your post but I’m getting error:

    /usr/bin/ld: /home/lecopivo/gcc412/gcc-build/./gcc/libgcc_s.so.1: version `GCC_4.2.0′ not found (required by /usr/lib/x86_64-linux-gnu/libstdc++.so.6)

    And I don’t know how to get rid of it.

  3. Hi,

    Thanks for the info. It helped me to compile gcc-4.1.2 on xubuntu 13.10. There were a couple of things I had to alter. The symlinks I created in /us/lib were:

    sudo ln -s x86_64-linux-gnu/crt1.o crt1.o
    sudo ln -s x86_64-linux-gnu/crti.o crti.o
    sudo ln -s x86_64-linux-gnu/crtn.o crtn.o

    I also had to edit the file gcc-4.1.2/gcc/config/i386/linux-unwind.h
    Line 139:
    from: struct siginfo *pinfo;
    to: siginfo_t *pinfo;
    Line 141:
    from: struct siginfo info;
    to: siginfo_t info;

    Hope that helps!

    1. I had to reinstall few hours ago and i had the same issue. Thanks for the fix, it’s already part of the guide and i can also say that it works also on ubuntu 14.04.

    1. make[2]: *** No rule to make target `../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a’, needed by `build/genmodes’. Stop.
      make[2]: *** Waiting for unfinished jobs….
      /bin/sh ../../gcc-4.1.2/gcc/../move-if-change tmp-optionlist optionlist
      echo timestamp > s-options
      make[2]: Leaving directory `/home/xman/gcc412/gcc-build/gcc’
      make[1]: *** [stage1_build] Error 2
      make[1]: Leaving directory `/home/xman/gcc412/gcc-build/gcc’
      make: *** [bootstrap] Error 2

      help me i am running ubuntu 14.04 64 bit

Leave a Reply