Problem with gcc 4.6 installation on ubuntu

2019-08-15 06:01发布

问题:

I am trying to install gcc 4.6 (mainly for having C++0x better supported) in my ubuntu 9.10 (via virtualbox). I referred to previous questions, but I am getting a different error.

I am referring this link for the installation. Now, I have done till the ./gcc-xx/configure ... step. Though it was giving some flex package related error. Mostly due to that make is also failing with below errors:

build/gengtype.o: In function adjust_field_rtx_def': /home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:978: undefined reference tolexer_line' /home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:1032: undefined reference to lexer_line' /home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:1042: undefined reference tolexer_line' ...............

Now this is giving me a hard time figuring it out because I have already flex/bison latest versions installed. I searched over internet for 2 days almost but no luck. Any help would be really appreciated. Also note that, I already have gcc 4.4 installed in /usr/bin/gcc and I have unzipped the gcc 4.6 tar in my home directory local folder.

[Note: I am also ok with installing ubuntu 11.10 too (which has gcc 4.6) as last resort. But I don't know if its .iso image is available.]

回答1:

I got this fixed. I followed following procedure: [Note: run all the commands with sudo, if you are not login as root. e.g. sudo ls -ltr; sudo make install;

  1. As mentioned in the link in my question, download the gcc4.6...tar file in a temporary place
  2. Now find the place where current gcc is stored. e.g. My earlier gcc4.4 was stored in /usr/lib/gcc/i486-linux-gnu. Which has a folder called 4.4, 4.4.1
  3. Create a folder named 4.6 (or 4.6.1/2/3 etc.) and put that .tar file inside it. Untar the file as shown in link.
  4. Follow all the procedure as per the link. Use nohup <command> & to track the logs. i.e. nohup make clean all & followed by tail -f nohup.out
  5. If some error comes, it means some package is missing. Mostly those package will be present in your current gcc version. You can install them there itself. For example, in my case zlib was missing. I ran sudo apt-get install zlib1g-dev libssl-dev and it worked fine. Otherwise download from internet and install it.
  6. Once your gcc is installed, you can simply check it using type gcc-4.6. In my case it showed that it's stored as /usr/local/bin/g++-4.6.
  7. Either you can use the same path to compile or you can put an alias in your bash/tcsh/ksh. e.g. /usr/local/bin/g++-4.6 -std=c++0x -Wall test.cpp


回答2:

FWIW Debian testing and unstable have gcc-4.6 as a standard package. So you can simply install that distro inside of virtualbox or, as I've done on my Ubuntu 11.04 server at home, via kvm. In the past, I also used to use dchroot build environments.

There may also be prepackaged gcc-4.6 binaries at launchpad.