Configure error for PECL Memcache on Ubuntu

This is the second time I've run into this error and I'm sick of Googling around for the answer. So I'm documenting it here. When preparing to compile code on Linux, one runs the configure command. If you don't have your compilers in order, you'll be faced with a message like this:


root@robert-desktop:/usr/src/memcache-2.1.0# ./configure --enable-memcache
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... /usr/bin/cpp-4.0
checking for C compiler default output file name... conftest.in
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

The problem can be figured out by looking at the environment variables for your C compiler:


env | grep CC
CC=/usr/bin/cpp-4.0

The answer to the problem; set the CC variable to the gcc program instead (I think this allows it to compile as C++ but don't quote me on that):

CC=/usr/bin/gcc-4.0 ./configure --enable-memcache

Comments

doesn't work

for me on a centos installation it doesn't work. I exported $CC and it shows in env but when I try and run `pecl install apc` it gives me this error. I'll keep looking.

also happens when /tmp mounted with the 'noexec' option

you could mount it with the 'exec' option but it is not very safe so in case it is a production system then please make sure you set it back to 'noexec' once you are done with the problematic installation.
mount with 'exec' option:
mount -o,remount,rw,exec /tmp
once you are done you should set it back to 'noexec' using:
mount -o,remount,rw,noexec /tmp

Ditto @Saggi for /var/tmp

If you have /var/tmp mounted "noexec" also, you'll need to enable exec for the install using Saggi's recipe:

mount -o,remount,rw,exec /var/tmp
And when you're done, set it back:
mount -o,remount,rw,noexec /var/tmp

Kudos

Thanks to Saggi Malachi and Stephen, your advice got my APC install completed! Also, thanks to the author!

Thank you Saggi Malachi,

Thank you Saggi Malachi, Stephen and of course the author!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options