LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-15-2003, 04:56 PM   #1
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Rep: Reputation: 15
libc


is there any linux application that don't uses the libc ?
 
Old 11-15-2003, 06:53 PM   #2
LinFreak!
Member
 
Registered: Jul 2003
Location: England
Distribution: slack9.1
Posts: 209

Rep: Reputation: 30
gawd knows, try looking at the dependencies of random programs!
 
Old 11-16-2003, 07:49 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: libc

Quote:
Originally posted by linuxanswer
is there any linux application that don't uses the libc ?
Apart from the kernel and libc itself, virtually none.
 
Old 11-16-2003, 08:50 AM   #4
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Original Poster
Rep: Reputation: 15
but when i compile a program are still necessary the library?
 
Old 11-16-2003, 10:45 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
In short: yes, you need libc.

However, it is possible, as the kernel and libc can be compiled, right?
But is is difficult. Even with this program:
Code:
int main()
{
     return 0;
}
if you compile it the normal way, say "gcc -o donothing donothing.c", then it gets linked with libc. You can check this with "ldd donothing".

There are command line options to gcc for not-linking in the standard libs. (check man gcc for -nostdlib or -nodefaultlibs). But I tried it, and it's not that easy. When you compile with (one of) these options, gcc doesn't even know how to get the program started anymore...

There is a website about creating tiny executables, (at least) some of which don't need libc, but they are using assembly. See:
http://www.muppetlabs.com/~breadbox/software/tiny/

Purhaps some sites about embedded systems have some info for you. Try googling for that.

Why do you want to do this, anyway?
 
Old 11-17-2003, 03:49 AM   #6
cuerty
LQ Newbie
 
Registered: Jul 2003
Distribution: Gentoo for me, Slackware for servers
Posts: 27

Rep: Reputation: 15
I don't know if you already know this but here it is :

libc isn't neccesary, it's necesary at compile time, cause it has the info that is needed by the program to 'do things'.

If I do a:

printf("Hi\n");

The way of do that printf in 'computer languaje' is stored in glibc. But when I'm making a binary of that you can choise if you want to make it to search on the libc (glibc, culibc, etc) or store it in the binary itself.

Making a big binary, with all the instructions inside, its called static.
Making a small binary, that has the direction of where are the instructions (glibc) is called shared.

The pros and cons: When using a static binary you don't need anything else. But the functions inside it, the store 'ways of do things' inside, are never gonna be actualized. Also the binary use to be to mouch big in filesize. The shared way (the stantard of the distros for distribute binarys) need some run time dependencis, glibc basic, mostly, if it needs other lib, like libpng for example, libpng also is gonna to need glibc.

I hope this is usefull in any way.
 
Old 11-17-2003, 10:44 AM   #7
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
But note that static linking can open a security hole. When a bug / security hole is discovered in a library, you can update the library to close the hole, but static linked binaries will still use there own statically linked version, including the hole.

Also, not only the size of the executable increases when linked statically, but also the memory footprint when it runs.
 
Old 11-17-2003, 11:15 AM   #8
cuerty
LQ Newbie
 
Registered: Jul 2003
Distribution: Gentoo for me, Slackware for servers
Posts: 27

Rep: Reputation: 15
Yes I ommit that cause I don't think necesary but is true.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libc.so.6(GLIBC_2.3), libc.so.6(GLIBC_2.3.2) needed for Linux 7.3.1 vivek_thampy Linux - Software 1 08-09-2004 04:12 PM
Libc? DARKRAIN Fedora 1 02-21-2004 10:11 AM
libc.so.6 alperen Linux - Software 1 09-15-2003 11:46 AM
libc.so verse libc.so.5 markstevens Linux - Software 4 06-19-2003 11:41 AM
libc.so.6 bash Linux - Distributions 2 08-09-2002 07:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration