We help IT Professionals succeed at work.

GCC - C compiler cannot create executables

tigermatt
tigermatt asked
on
Medium Priority
1,681 Views
Last Modified: 2012-05-11
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?
Comment
Watch Question

Top Expert 2011

Commented:
> 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.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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.
Top Expert 2011

Commented:
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.
tigermattSite Reliability Engineer
CERTIFIED EXPERT
Most Valuable Expert 2011

Author

Commented:

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
tigermattSite Reliability Engineer
CERTIFIED EXPERT
Most Valuable Expert 2011

Author

Commented:

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
tigermattSite Reliability Engineer
CERTIFIED EXPERT
Most Valuable Expert 2011

Author

Commented:

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.
Top Expert 2011

Commented:
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.
Top Expert 2011

Commented:
Top Expert 2011

Commented:
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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>
Consultant
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
@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.
Michael EagerConsultant

Commented:
@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.  
Top Expert 2011

Commented:
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.  
Michael EagerConsultant

Commented:
@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.  

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.