LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2010, 09:27 AM   #1
pmil
Member
 
Registered: Jul 2008
Posts: 43

Rep: Reputation: 15
Question Glibc questions


Hi all,

AFAIK, in addition to implementing the standard C library, glibc provides wrappers for system calls, threading support, and basic application facilities.

So because of that, glibc that will be used on my target system should be built based on the kernel version running on my target, right?

Based on the above, I am trying to build a glibc version for my target machine's kernel. However, I don't know to to build a glibc library for a target system and also where on the target's filesystem should be put? In which location Linux will start looking for the libraries required for a program to run (should I create an /etc/ld.so.conf file)?

Thanks a lot for any help.

Last edited by pmil; 01-08-2010 at 09:28 AM.
 
Old 01-08-2010, 10:07 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
Glibc alone will not do at all.

The important thing is gcc, which creates objects depending
on the glibc, which was used to build the gcc.

You will probably need a complete tool chain :
1) binutils ( includes the ld / linker files ).
2) gcc
3) glibc + some headers from the target kernel.

Location : /home/"user"/tools/ or /opt/tools/
or /usr/local/tools/ .. whatever you like.
  • Important : tell us, which host you have, like
  • Fedora 12, Ubuntu 9.10 etc. ( architecture ? )
  • And please specify the target, + its architecture.
  • Architecture can be x86, x86_64, arm, ppc, etc.
.....

Last edited by knudfl; 01-08-2010 at 10:10 AM.
 
Old 01-08-2010, 10:19 AM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by pmil View Post
...running on my target...
Is the target an embedded system? Is the target a desktop computer?
 
Old 01-08-2010, 12:21 PM   #4
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Thank you all for your interest.

My host is Ubunty 9.10 and my target is an Atom 330 (x86). The target machine is used as an embedded system. My host's kernel version is 2.6.31-14-generic and the host's glibc version is 2.10.1-0ubuntu15.

I am using the GCC provided by Ubuntu's "build-essesntial" package. The version of GCC is 4.4.1.

What I have understand is that I need to somehow install the glibc version which I used to compile my programs to the target's filesystem so that dynamic linking can be done. Can you advise me on how to do so?

Let's say that I have a hello world program like the following, which is dynamically linked:

Code:
#include <stdio.h>
int main() {
        printf("Hello world!\n");
        return 0;
By using ldd, I see the shared libraries needed for its execution:

Code:
	linux-gate.so.1 =>  (0x00723000)
	libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00bd0000)
	/lib/ld-linux.so.2 (0x00b96000)
At run time, the program will search for the printf() routine. Where it will search for the required library? Will it search under the /lib/ folder of the file system? How and where should I put glibc on the target's filesystem in order to be able to do dynamic linking?

Thanks in advance.

Last edited by pmil; 01-08-2010 at 12:33 PM.
 
Old 01-08-2010, 01:04 PM   #5
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by pmil View Post
...my target is an Atom 330 (x86). The target machine is used as an embedded system.
Does the target have an hard drive? Does it use a flash file system? How much space do you have on your file system?

Are you able to boot the target to a bash prompt?
 
Old 01-08-2010, 04:37 PM   #6
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by David1357 View Post
Does the target have an hard drive? Does it use a flash file system? How much space do you have on your file system?

Are you able to boot the target to a bash prompt?
No, my target doesn't have a hard drive and it uses an initrd as its main filesystem. It has 1GB of RAM and yes, I am able to boot the target to a bash prompt.

Thanks.
 
Old 01-09-2010, 12:57 PM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
'ls /lib/libc-2*'

.. will show which glibc you already have on the atom system.

Replacing it with another version :
Will most often break the system.

Glibc is the system. ( Together with the kernel.)
.....
 
Old 01-09-2010, 05:44 PM   #8
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by knudfl View Post
'ls /lib/libc-2*'

.. will show which glibc you already have on the atom system.

Replacing it with another version :
Will most often break the system.
Let me clarify this. My target's filesystem is empty (there is nothing under /lib). It only has the absolutely necessary things for having a running system. All I am asking is how can I put a glibc version on it. AFAIU, I need to put the same version which is used on the host for the compilation of the user applications which I am gonna use.

Thanks.

Last edited by pmil; 01-09-2010 at 05:46 PM.
 
Old 01-10-2010, 01:04 PM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
Please define running ..

I guess, you have a few commands available.
Can you do the command 'ls' ?
Example from "tty Linux", a Linux OS, total 8 MB :
ldd /bin/ls
.. the reply is : libc.so.6 , which is glibc.

May be you have a ' libc-2.x.so in another location ?
Please try : ls -R / | grep libc-2*

EDIT : Or : ls -R / | grep libc*
.....

Last edited by knudfl; 01-11-2010 at 01:17 PM.
 
Old 01-11-2010, 10:14 AM   #10
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by pmil View Post
...I am able to boot the target to a bash prompt.
Then you should already have libc installed in the correct place:
Code:
[user@machine:~]:ldd $(which bash)
        linux-gate.so.1 =>  (0xb80a3000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb803d000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb8039000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7eda000)
        /lib/ld-linux.so.2 (0xb8089000)
If you are using some form of embedded Linux (e.g. uClinux), then you will have to build your application against whichever version of libc you built into your image.
 
Old 01-11-2010, 10:19 AM   #11
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by pmil View Post
My target's filesystem is empty (there is nothing under /lib). It only has the absolutely necessary things for having a running system.
Did you statically compile your version of bash?
Are you using uClinux and busybox?

Quote:
Originally Posted by pmil View Post
All I am asking is how can I put a glibc version on it. AFAIU, I need to put the same version which is used on the host for the compilation of the user applications which I am gonna use.
It may seem like you are asking a very simple question. The problem is that it is not a simple question. We need more information before we can help you.

How did you build the kernel on your target?

The answer to that question will tell us how to help you get the correct libc on your target.
 
Old 01-13-2010, 10:27 AM   #12
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by David1357 View Post
Did you statically compile your version of bash?
Are you using uClinux and busybox?
Yes, busybox is statically compiled (that's why it works!). I am not using uClinux, just a vanilla kernel.

Quote:
Originally Posted by David1357 View Post
It may seem like you are asking a very simple question. The problem is that it is not a simple question. We need more information before we can help you.

How did you build the kernel on your target?

The answer to that question will tell us how to help you get the correct libc on your target.
Thank you very much for your interest! I've built the kernel using the host's gcc (and eventually host's glic version). So, if I am about to use the host's gcc and glibc to build applications, should I copy the /lib/ folder of the host to /lib/ of the target's filesystem to have support of dynamic linking with glibc?

I know it's not the smartest/best way of doing it but it will work at all?

Thanks!
 
Old 01-13-2010, 01:27 PM   #13
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by pmil View Post
Yes, busybox is statically compiled (that's why it works!).
I am just trying to get a picture of what you have and how it works.

Quote:
Originally Posted by pmil View Post
I've built the kernel using the host's gcc (and eventually host's glic version).
ok. That is very useful information.

Quote:
Originally Posted by pmil View Post
I know it's not the smartest/best way of doing it but will it work at all?
The only way to find out is to try it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Questions of the Glibc-2.7 universe... xadrith Linux - Newbie 4 06-22-2008 08:51 PM
Where can I post glibc build failure questions ? rekhakp Linux - Software 0 04-27-2005 05:37 PM
Replacing glibc using linuxthreads for glibc using nptl (native positx thread library CestusGW Linux From Scratch 4 01-20-2005 08:26 AM
3rd LFS build (this time on x86-64): about GCC and GLIBC and other questions... ParticleHunter Linux From Scratch 1 08-16-2004 11:47 AM
Questions Re: downgrading glibc to 2.3.2 on RedHat Enterprise colmmagoo Linux - Software 2 08-03-2004 09:42 AM


All times are GMT -5. The time now is 02:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration