Link to home
Start Free TrialLog in
Avatar of tigermatt
tigermattFlag for United Kingdom of Great Britain and Northern Ireland

asked on

GCC - C compiler cannot create executables

I am attempting to configure Asterisk CDR logging to MySQL on an Asterisk 1.8.3.2 box.

I have already installed MySQL and created the database / user. This is working correctly. /etc/asterisk/cdr_mysql.conf is configured.

With all the required dependencies installed, I am unable to run ./configure:

root@Hutch:/usr/src/asterisk-1.8.3.2# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/usr/src/asterisk-1.8.3.2':
configure: error: C compiler cannot create executables
See `config.log' for more details.

Open in new window

Unfortunately, gcc doesn't seem to be working. I have removed and reinstalled as much as I can without removing 974MB of packages and disrupting all the core system on the Linux box. This hasn't fixed the problem. I don't quite understand why.

Any ideas before I backup the config and format the box?
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

> See `config.log' for more details.
Could you post the config.log?

Besides, your Linux need to install "glibc-headers" package which all the header files.
Avatar of arnold
run gcc and see what it outputs.
My guess is that you will get a message saying to install run apt-get install gcc which you should do and then you will have a working gcc (C compiler) on the system.
Check this post
http://www.linuxquestions.org/questions/linux-newbie-8/checking-whether-the-c-compiler-gcc-works-no-199614/#post1020828

There is simple c code and compile it.
If you got the same error message : " stdio.h: No such file or directory"
Then your Linux are missing system headers files in /usr/include/, which is glibc-headers package.
Avatar of tigermatt

ASKER


wesly_chen,

I get this:

root@Hutch:/home/matthew# gcc -o simple simple.c
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
root@Hutch:/home/matthew#

Open in new window


arnold,

Running gcc itself seems to work correctly:

root@Hutch:/home/matthew# gcc
gcc: no input files

Open in new window


-Matt

Attached is the config.log as requested.

Digging into the log it seems to show the same error regarding -lc which I had in wesly_chen's example above.

-Matt
config.log

Apologies for the multiple posts.

arnold,

apt-get install gcc - I am told I already have the newest version. I have removed/reinstalled to no effect.

wesly_chen,

I can't find a glibc-headers package in the repository to install.
You missing glibc, need to install glibc, glibc-headers and glibc-devel.
If your Linux uses "rpm", please post
# rpm -qa |grep -i glibc
and post the result here.
In Ubuntu, 'libc6' is available thru your package manager (I used Synaptics) and that's the way you should install it.  "glibc-source" and glibc-doc" are also available if you need them.  They are not installed with gcc for some reason.  Has to be done separately.
apt-get install glibc should do the trick as well
or do apt-get search glibc and then apt-get install <the list of found items>
ASKER CERTIFIED SOLUTION
Avatar of Michael Eager
Michael Eager
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@eager, the standard Ubuntu release does not include gcc or it's libraries.  They are in the repositories as separate items for download.  Ubuntu users have been complaining about the separate downloads for at least 5 years now.
@DaveBaldwin -- the standard Ubuntu release *does* include glibc, like ever other distro.  Yes, glibc-headers are not installed by default, which is an annoyance when you compile something with gcc, because *gcc* will fail when the include files are not found.  LD not being able to find libc.so is not caused by missing header files.  

As the OP found, trying to install glibc will (wisely) result in a message saying it is already installed.  
Well, Asterisk Linux is a function specific Linux OS for PBX or phone system.
Early version of Asterisk used Fedora Core 3.

Based on the error messages,
> /usr/bin/ld: cannot find -lc
It seems that OS is stripped out part of glibc function or libraries.
For glibc-headers, we can check
/usr/include
directory to see the content.

So I recommended to re-install full version of glibc.
However, install glibc is not easy if there is not precompiled package from the OS distributor.

Above just my conclusion. It might not correct.  
@wesley -- it is difficult to run programs on a Linux system which does not include libc.so.  Only programs which are linked statically can run.  

It's easy to find out whether libc.so is installed and where it is located:

$ find /lib -name libc.\*

Installing new versions of glibc is very problematic and ill-advised.  If glibc is not built for the *exact same* kernel, including all patches, it's possible hat the kernel interface will have changed.