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

manjunatha sirinivasan manju903srini at yahoo.co.in
Wed Sep 27 09:37:32 UTC 2006


Hi 

   
application program linking problem with uClibc++:
-------------------------------------------------- 
 Iam doing porting job for uClibc (0.9.28) and
uClibc++(0.2.0) for MIPS architecture.I can  built
both uClibc and uClibc++ libraries successfully with 
help montavista cross toolchain(mips_fp_be-). My host
machine is x86.
uClibc configuration contains(minimum info) :
    architecture MIPS 
    processor    MIPS1
    Endianness   big 
    It points to custome kernel header path of target
board which is used for booting. uclibc is configured
for shared library. 
uClibc++ configuration contains(minimum info):
    architecture MIPS 
    processor    MIPS1
    Endianness   Big                 
    STL & Exception & RTTI support 
uClibc++ is configured as shared library. 

I have placed both uclibc, uClibc++ libraries under 
/lib directory of target root filesystem in host
machine.   

For compilation and linking, path refered is 
/opt/montavista/pro/devkit/mips/fp_be/target/lib.
I have placed my uClibc and uClibc++  libraries for
compiler (mips_fp_be-gcc) at the above path.
   
I can compile and link a sample C code by using 
uclibc libraries. Executable is running successfully
in target board. 

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'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `free at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `__ctype_b_loc at GLIBC_2.3'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `realloc at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fcntl at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `strncpy at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `strcmp at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `memcmp at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fread at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fopen at GLIBC_2.2'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fclose at GLIBC_2.2'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fseek at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fflush at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `strncmp at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `clearerr at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fputc at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `memset at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `stdin at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `sscanf at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `memcpy at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `snprintf at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `ftell at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `dl_iterate_phdr at GLIBC_2.2.4'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `__cxa_atexit at GLIBC_2.2'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `__strtol_internal at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `malloc at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `stdout at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fileno at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fprintf at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `strlen at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `__errno_location at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `stderr at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `feof at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `fwrite at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `memmove at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `ferror at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `isspace at GLIBC_2.0'
/opt/montavista/pro/devkit/mips/fp_be/target/lib/libuClibc++.so:
undefined reference to `abort at GLIBC_2.0'
collect2: ld returned 1 exit status
------------------

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?

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.  

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

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

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?

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


Building of uClibc with cross toolchains:
-----------------------------------------
I successfully  built cross binutils and cross
compiler  (mips-elf-gcc) without any problem. 

But when go for building uClibc with cross
compiler(mips-elf-gcc) it showed the error as:

make[3]: Entering directory
`/root/Project-Genesis1-uClibc-scratch/uclibc-src/uClibc-0.9.28/libc/string/mips'
mips-elf-gcc  -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing  -mips1  -fno-builtin -nostdinc
-D_LIBC -I../../../include -I.  -Os  
-mno-split-addresses -isystem
/usr/local/lib/gcc-lib/mips-elf/3.3.2/include -DNDEBUG
-fPIC  -c memcpy.S
-o memcpy.o
memcpy.S: Assembler messages:
memcpy.S:72: Error: illegal operands `lw t4,16($5)'
memcpy.S:73: Error: illegal operands `lw t5,20($5)'
memcpy.S:74: Error: illegal operands `lw t6,24($5)'
memcpy.S:75: Error: illegal operands `lw t7,28($5)'
memcpy.S:82: Error: illegal operands `sw t4,-16($4)'
memcpy.S:83: Error: illegal operands `sw t5,-12($4)'
memcpy.S:84: Error: illegal operands `sw t6,-8($4)'
memcpy.S:86: Error: illegal operands `sw t7,-4($4)'

This may be registers t4,t5,t6,t7 are not defined. Is
there any soluttion to come out of this error?  





 


  






  










  Regards,
   
  Manjunatha Srinivasan N




		
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/



More information about the uClibc mailing list