Re: Crosstools and dynamic libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



none none wrote:

> I have tried to produce executable code for my embedded linux system with the cross-gcc
> when I try to run it on my target system I get the following error:
> bash$./hello_world
> ./hello_world: error in loading shared libraries
> : undefined symbol: __libc_start_main
> I know that I am supposed to export to my target system the dynamic libraries I need.

No, no ! Totally vice versa - you should copy the runtimes and development parts from your target system onto the cross host before starting to build the cross GCC there! If you would build a native GCC onto your target system, it would use the '/lib', '/usr/include' and '/usr/lib' stuff on it... Totally in the same way the cross GCC would need to use this same stuff when creating executables for this target system. So you only need to build binutils and GCC for your cross-host, they must run there meanwhile the target C library is something which was
produced for the target system, not for the host system!

If the target system hasn't any C library for it yet, then you must produce it (on the cross host)!

> The problem is that I cannot find the libraries neither in crosstools directory nor in eldk dir.
> Where are they?

Just look at '/lib' (the runtimes) and '/usr/lib' (development libraries) or the "install CD"s for your embedded Linux (the development parts aren't surely installed)! Please look 'bash' with 'ldd' in
your Linux target system :

  bash$ ldd /bin/bash

A 'bash' in a Linux distro lists quite a lot runtimes, so in order to run bash, one should have them all already installed! When you could run 'bash' then you must have some runtimes installed!

> Did not they created when the crosstools or eldk installed? Do I have to install or make anything
> else I have not understood?

You haven't understood that a crosstoolchain will be made to produce apps for the target system, not for something else! The goal in 'crosstool' and 'eldk' is to create the target system from scratch using the produced crosstoolchain, and the self-made runtime C libraries will be installed onto the
target system (which hadn't anything yet) !

> Furthermore when I give ldd hello_world in my host platform I get the message:
> not a dynamic executable
> where in my target system I get
>  libc.so.6 => /lib/libc.so.6 (0x30000000)
>  /lib/ld.so.1 => /lib/ld.so.1 (0x08000000)

So you ALREADY HAVE the required '/lib/libc.so.6' and '/lib/ld.so.1' on your target system! But you DIDN'T USE THEM in your crosstoolchain although for all sanity you should have done so! Then the apps produced there would have been linked against these linktime/runtime libraries. The crosstoolchain you made was targeted for SOMETHING ELSE, and uses some other target libs, so there is no guarantee that the executables made with it could run on your target system :-(


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux