Computing.Net > Forums > Linux > ubuntu and gcc

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ubuntu and gcc

Reply to Message Icon

Name: cactus
Date: July 21, 2007 at 04:39:11 Pacific
OS: Windows XP
CPU/Ram: Intel 1GB
Product: Intel
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Guy
Date: July 22, 2007 at 06:09:21 Pacific
Reply:

If you post the offending source you will probably get more help.


0

Response Number 2
Name: cactus
Date: July 23, 2007 at 00:49:46 Pacific
Reply:

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.



0

Response Number 3
Name: ernie
Date: July 23, 2007 at 09:47:06 Pacific
Reply:

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


0

Response Number 4
Name: Guy
Date: July 23, 2007 at 17:30:04 Pacific
Reply:

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


0

Response Number 5
Name: cactus
Date: July 24, 2007 at 01:50:17 Pacific
Reply:


hi all

i 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


0

Related Posts

See More



Response Number 6
Name: cactus
Date: July 27, 2007 at 01:42:38 Pacific
Reply:


hi all

have run the following 2 commands, both yielding the same result.

locate stdio.h
AND
dpkg -S stdio.h

RESULT:
/usr/lib/perl.5.8.8/CORE/nostdio.h

I 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


0

Response Number 7
Name: ernie
Date: July 27, 2007 at 07:06:02 Pacific
Reply:

Quote:
"locate stdio.h
AND
dpkg -S stdio.h
RESULT:
/usr/lib/perl.5.8.8/CORE/nostdio.h"

End Quote

If 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


0

Response Number 8
Name: Guy
Date: July 27, 2007 at 14:16:28 Pacific
Reply:

cactus - On that Ubuntu system install package:

libc6-dev

and any/all prerequisites.

Then try again, and let us know the results.

Guy



0

Response Number 9
Name: cactus
Date: July 28, 2007 at 18:08:30 Pacific
Reply:

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.sh

and 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


0

Response Number 10
Name: ernie
Date: July 28, 2007 at 21:22:58 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Linux driver for Express ... Which Disto for Beginner?



Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: ubuntu and gcc

dual boot ubuntu and fedora www.computing.net/answers/linux/dual-boot-ubuntu-and-fedora-/30212.html

Ubuntu and win98 networking. www.computing.net/answers/linux/ubuntu-and-win98-networking/28158.html

linker and gcc question www.computing.net/answers/linux/linker-and-gcc-question/12712.html