App. progam linking with uClibc++ and building of uClibc with cross toolchains

Garrett Kajmowicz gkajmowi at tbaytel.net
Thu Sep 28 01:24:46 UTC 2006


On Wednesday 27 September 2006 09:37, manjunatha sirinivasan wrote:
> Hi
>

<snip>

> But it failed to compile C++ code. I am getting
> following error on executing following command:
>
>  mips_fp_be-g++  -nodefaultlibs  -L
> /opt/montavista/pro/devkit/mips/fp_be/target/lib
> -luClibc++ -L
> /opt/montavista/pro/devkit/mips/fp_be/target/lib
> libgcc.a  hello.cxx -o hello
>
> Error----------------------
>
> /opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
> undefined reference to `strcpy at GLIBC_2.0'

wash, rinse, repeat.

> The C++ code (hello.cxx) is:
>
> #include <iostream>
> #include <stdio.h>
> using namespace std;
> using std::cout;
> using std::endl;
> void abort(void);
> int main()
> {
> cout<<"Hello World" << endl;
> printf("Hello World \n");
> return 0;
> }
>
> Queries:

> --------
>   If montavista complier (mips_fp_be-gcc) configured
> for glibc,  how it is possible to successfully   built
>  new uClibc and uClibc++ libraries  and making uClibc
> libraries  to work with applicaiton program for mips.
> But why it is failing to make use of uClibc++
> libraries for linking with application program?

Simple.  The -nodefaultlibs flag tells GCC to to link against anything that is 
not being specifically linked against.  You aren't linking against the C 
library.  Thus the linker can't find things like strcpy, etc.   Note the 
@GLIBC part - the symbol is missing from glibc because you aren't linking 
against it.  

Also, if you built uClibc++ as a dynamic library, why is it that you linking 
against the static version (ending in .a)?

> Is any kernel headers information has to play any role
> with uClibc++? Since i don't have any like such option
>  in uClibc's configuration.

There should be no kernel header material involved in uClibc++.  I can't speak 
for uClibc - maybe others on the mailing list can help you?

> Why the functions like fopen, fwrite in library libc
> of uclibc  is not linking properly with libuClibc++.so

You aren't linking in the C library.  Thus they aren't linked in.  I created 
the wrapper script to link in the bits needed.  You aren't using it, and so 
you are running into problems.

> Is there any reference for "compilation and linking
> steps" in the internet?

http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=%22compilation+and+linking+steps%22&btnG=Search

Results 1 - 10 of about 452

Yes.

> If i do,
>    mips_fp_be-g++ -c  hello.cxx -o hello.o
> compilation is happening  successfully(it is resolving
> all header files).But why it is failing  at linking
> even though all libraries are present?

Just because a library is present doesn't mean the library is being linked in.  
That *why* we have linkers.

> How for uClibc and uClibc++ are dependent each other?

uClibc and uClibc++ are not dependent on each other.  In fact, I do very 
little testing against uClibc directly.


> Building of uClibc with cross toolchains:

OK - these questions should have been part of a separate email as they are on 
a different topic.  There isn't much I can do to help you, but it does look 
like the file you are attempting to assemble has invalid instructions in it.



-     Garrett



More information about the uClibc mailing list