Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi all
i've just installed ubuntu, and when i try to compile something with gcc it seems to work but tells me that stdlib.h and stdio.h are not recognised as files, and that i'm implicitly declaring the built-in printf.
anyone know how to fix this? how can it run gcc but not recognise the standard libraries? gcc is definitely there (i've run gcc -v and it gives me a recent version number, and as i said, it is attempting to compile).
any help would be appreciated.cheers
cactus

hi guy
the source was the standard hello world! program which had already compiled and run with the knoppix live cd, so there's nothing to it. the problem is with the ubuntu installation of gcc.

If we see the output from the compilation,
we may be able to deduce what is missing.You may have the gcc package installed, but
are other development packages needed? I use
Mandriva here so I am unsure how Ubuntu
organizes their packages and dependencies. I
have found that installing the kernel source
package insures the installation of any
additional software needed for development.
I also get the impression that some
distributions also need to install packages
containing header files for development (the
header files are included in the packages
named {packagename}-devel in the Mandriva
distribution).Even though all you are doing is compiling a "Hello World" program, the full output from execution of the compiler may yield useful information to those who frequent this forum and do software development. The more information we have, the better the chance we will see what the trouble is and be able to help. You should understand that the people who frequent forums such as this one are not being paid for their time and will ask for better information if what is provided is believed to be inadequate. For many of us, this is a way of giving a little something back to the Linux community, but it is not an obligation. With that said, if you expect others to do all the work or guess at what the problem may be, you will find that you do not get much useful help. This link may help: How to ask questions the smart way. Please do not take offense at my reply. My only intent is to help,
Ernie Registered Linux User 247790
ICQ 41060744

ernie - thanks for reminding me that the compiler output might be important!
cactus -
post the source
post compiler output
post output of these commands:locate stdio.h
dpkg -S stdio.h

hi alli appreciate your attempts to help, and i'll get onto the request. i can't get onto the internet via ubuntu, so i'm in windows when i post. i hadn't posted the precise compiler output but my first post was intended to say that i get 2 standard messages with the usual wording that i can't now precisely recall:-
1. the standard message when gcc can't find an include file - something to the effect of "cannot find file stdib.h" and "cannot find file stdio.h", then;
2. identifying the main function and the WARNING about implicitly declaring an in-built function, in this case "printf".that's the whole output. sorry, but i can't remember the exact words of those.
the source was variations of this:-
#include <stdlib.h>
#include <stdio.h>int main()
{
printf("Hello world!");
return 0;
}i also tried leaving off the .h extensions, using " " rather than < >, and even including <cstdlib> variations.
i'll check the 2 other suggested commands when i get back onto ubuntu.
thanks for efforts to date.
cactus

hi allhave run the following 2 commands, both yielding the same result.
locate stdio.h
AND
dpkg -S stdio.hRESULT:
/usr/lib/perl.5.8.8/CORE/nostdio.hI also tried downloading gcc and the tiny compiler, but both required a gcc installed already, so they wouldn't install.
This is on a fresh install of ubuntu from the CD. gcc -v gives me an up-to-date version, but when I try to run code it tells me it can't find stdio.h or stdlib.h.
Has anyone else had this problem?
Cheers
cactus

Quote:
"locate stdio.h
AND
dpkg -S stdio.h
RESULT:
/usr/lib/perl.5.8.8/CORE/nostdio.h"
End QuoteIf both return the same result, then the
stdio.h file is not installed. The result
you have here is a part of Pearl
(nostdio.h).I use Mandriva Linux 2007.1 (Spring) here.
It uses an rpm based package management
system. glibc-devel is the package with the
header files such as stdio.h. There will
also be a glibc package which is basic to
nearly any Linux system, but if you search
for glibc, you may find the development
package as well.HTH,
Ernie Registered Linux User 247790
ICQ 41060744

cactus - On that Ubuntu system install package:
libc6-dev
and any/all prerequisites.
Then try again, and let us know the results.
Guy

hi
i'm not sure that i properly understood the latest suggestions, but here are some results:-
did 'locate' on the hard drive for both glibc and libc6-dev. i was returned to the command line with no feedback, no results.
also did:-
dpkg -S glibc
result:-
libc6: /etc/init.d/glibc.shand dpkg -S libc6-dev - no results
which i'm guessing is a shell executable, which i tried running (really just for the hell of it), but nothing appeared to happen.
i then did a search via the GUI search program:-
this produced several files with glibc in their names (but not glibc-devel) and promising looking folders with gcc in their names.
i think i may need generic advice, so i can play around with it. What am i looking for to install? if i find it, what do i do with it?
i realise guy's post may have been trying to tell me that (i didn't understand whether he was telling me to install from the CD, on the assumption i knew how to do it, or whether he was telling me where to find it. the word 'install' in his post could be a verb, noun or adjective!). should i do a search of the iso CD? if i find libc6-dev on that, what do i do?
incidentally, in the GUI package manager it seems to be telling me that gcc is installed, which of course is the same result as command line gcc -v.
cheers
cactus

I will try to keep this as clear as
possible.The reason you can not compile your "Hello
World!" program is that the libc6-dev
package is not installed. It has the files
you need (stdib.h and stdio.h). Install it
(libc6-dev) using your package manager. If
the package manager asks to install any
additional packages with the libc6-dev
package, install them too. Doing this should
fix your trouble.Ernie Registered Linux User 247790
ICQ 41060744

![]() |
Linux driver for Express ...
|
Which Disto for Beginner?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |