Search code examples
pythongccinstallationgdal

c++ compiler not installed on this system


I'm trying to install a Python package GDAL http://trac.osgeo.org/gdal/wiki/GdalOgrInPython.

I've successfully installed the dependencies: Python 2.7.8, Numpy 1.8.2, libgdal 1.10.0, and gdal-devel. However, when I use this command:

pip install GDAL==1.10.0

I got some errors:

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/local/include/python2.7 -I/root/.local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o

gcc: extensions/gdal_wrap.cpp: C++ compiler not installed on this system

error: command 'gcc' failed with exit status 1

Here is my system information:

# lsb_release -a

LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: CentOS

Description: CentOS release 5.10 (Final)

Release: 5.10

Codename: Final

# cat /proc/version

Linux version 2.6.18-274.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Fri Jul 22 04:43:29 EDT 2011

And my compiler information:

# gcc --version

gcc (GCC) 4.4.6 Copyright (C) 2010 Free Software Foundation, Inc.

# g++ --version

g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54) Copyright (C) 2006 Free Software Foundation, Inc.

I also tried to use:

# pip install --no-install GDAL==1.10.0
# cd /tmp/pip_build_root/GDAL && python setup.py build

But it leaded to the same errors.

Finally, I tried to build it from source by:

# ./configure --with-python
# make
# make install

Unfortunately, the same errors still appeared.

I have no idea about that. Could you give me some hints? Thanks.


Solution

  • gcc (GCC) 4.4.6 Copyright (C) 2010 Free Software Foundation, Inc.

    g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54) Copyright (C) 2006 Free Software Foundation, Inc.

    So you do have a C++ compiler… but you don't have the C++ compiler for the toolchain you're using, gcc 4.4.6.

    So, you have two options:

    1. Install g++ 4.4.6. Most likely this is just yum install gcc-c++ or yum install gcc44-c++ or something similar.
    2. Configure with gcc 4.1.2 instead of 4.4.6. Assuming that 4.1.2 is available as gcc-4.1 or something like that, this may just mean doing an export CC=gcc-4.1 before the configure or setup step, but you may instead need to use some toolchain-selection command.

    The first one is almost certainly a better idea.

    If you need help on either of those two, that's really more of a question on using Unix or setting up RHEL/CentOS than on programming (especially Python programming!); this question at Unix StackExchange may be helpful for both.