Member Avatar for Member #814414

Hi,

I'm trying to install GCC 4.5.1 on Ubuntu for C++ programming.

So far, I've tried a myriad of different commands in Terminal to try to update GCC (the preinstalled version is 4.3.2), but none of them seem to work. When I go to update my packages with Synaptic Package Manager, it gives me a bunch of errors telling me that it failed to connect to the repository.

Also, I've tried just compiling a C++ file with the preinstalled GCC, and it tells me that cc1plus wasn't found.

Any suggestions?

Dani AI

Generated

Two separate problems are hinted at in the original post: APT cannot reach repositories (so new packages won’t install) and the C++ frontend (cc1plus) is missing or broken. was right to point toward installing the standard C/C++ toolset, and was right that a newer Ubuntu will give a newer compiler — but both of those depend on APT being able to fetch packages first. The immediate goal is to gather a few facts so you can choose the right fix.

Run these checks to collect useful evidence (run as root or prefix with sudo):

cat /etc/lsb-release
grep -H '^deb' /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null
ping -c 3 archive.ubuntu.com
apt-cache policy g++
ls -l /usr/lib/gcc/*/*/cc1plus
dpkg -S cc1plus
dpkg -l | grep -E 'g\+\+|gcc|libstdc'

If ping/apt-cache lookups fail, fix the repository connectivity first. On older or end-of-life Ubuntu releases the normal mirrors have been moved, so either update your sources.list to the "old-releases" mirror for that release or upgrade to a supported Ubuntu. If the system can reach the archives but package installation failed previously, repair the package state and then reinstall the C++ packages:

  • Repair package database and dependencies (configure pending packages, fix broken installs).
  • Reinstall the compiler packages using your package manager (Synaptic or the command-line APT front end) so the missing cc1plus binary is restored.

If you specifically need GCC 4.5 on a newer system, use the distribution-provided newer release or a maintained toolchain repository rather than trying to mix repository versions. Quick checklist: confirm Ubuntu release, confirm working APT mirrors (or switch to old-releases if EOL), run package-repair steps, then reinstall the C++ toolchain. This addresses the two root causes raised by and without assuming a particular install command was already successful.

Recommended Answers

All 4 Replies

hi coil,
try
sudo apt-get install build-essential
try
which g++
will give you the path to g++ binary. If this doesn't work, try
sudo apt-get install g++

Hope this works[assuming your OS Ubuntu].

Cheers
Sarma CSMG

What version of Ubuntu are you using? If you're using a version that has 4.3 in the repositories, you will have a very hard time trying to upgrade it to 4.5. It might be easier to install a new version of Ubuntu than it is to upgrade the compiler.

Member Avatar for Member #814414

Thanks for your replies!

I did try running the build-essential commands and trying to directly install g++ with sudo apt-get, but neither of them solved my problem.

Ishara: So if I install version 10, I assume that GCC 4.5 will be installed - are there any other utilities I need to install then for C++ programming, or is that it?

If you install 10.10 and install 'g++' through Synaptic, you should be set up to compile c++ code with no further work. I don't know if the compiler is installed by default, but you should be able to get it through the repository.

Out of curiosity, when you compile your c++ code, you are trying to compile it using "g++ file.cpp", right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.