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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-08-2010, 09:27 AM
|
#1
|
Member
Registered: Jul 2008
Posts: 43
Rep:
|
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.
|
|
|
01-08-2010, 10:07 AM
|
#2
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
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.
|
|
|
01-08-2010, 10:19 AM
|
#3
|
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
Rep:
|
Quote:
Originally Posted by pmil
...running on my target...
|
Is the target an embedded system? Is the target a desktop computer?
|
|
|
01-08-2010, 12:21 PM
|
#4
|
Member
Registered: Jul 2008
Posts: 43
Original Poster
Rep:
|
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.
|
|
|
01-08-2010, 01:04 PM
|
#5
|
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
Rep:
|
Quote:
Originally Posted by pmil
...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?
|
|
|
01-08-2010, 04:37 PM
|
#6
|
Member
Registered: Jul 2008
Posts: 43
Original Poster
Rep:
|
Quote:
Originally Posted by David1357
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.
|
|
|
01-09-2010, 12:57 PM
|
#7
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
'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.)
.....
|
|
|
01-09-2010, 05:44 PM
|
#8
|
Member
Registered: Jul 2008
Posts: 43
Original Poster
Rep:
|
Quote:
Originally Posted by knudfl
'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.
|
|
|
01-10-2010, 01:04 PM
|
#9
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
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.
|
|
|
01-11-2010, 10:14 AM
|
#10
|
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
Rep:
|
Quote:
Originally Posted by pmil
...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.
|
|
|
01-11-2010, 10:19 AM
|
#11
|
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
Rep:
|
Quote:
Originally Posted by pmil
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
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.
|
|
|
01-13-2010, 10:27 AM
|
#12
|
Member
Registered: Jul 2008
Posts: 43
Original Poster
Rep:
|
Quote:
Originally Posted by David1357
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
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!
|
|
|
01-13-2010, 01:27 PM
|
#13
|
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
Rep:
|
Quote:
Originally Posted by pmil
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
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
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.
|
|
|
All times are GMT -5. The time now is 10:32 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|