Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I installed codesourcery cross compile toolchain for mips32 architecture on my WIN 7 machince. I want to first compile a simple 'factorial' binary for my router which is based on MIPS32. From little search on the internet, I found it is based on MIPS32 big-endian.

#cat /proc/cpuinfo
system type             : 96338W2
processor               : 0
cpu model               : BCM6338 V1.0
BogoMIPS                : 239.20
wait instruction        : no
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : no
unaligned access        : 1269919
VCED exceptions         : not available
VCEI exceptions         : not available

# cat /proc/version
Linux version 2.6.8.1 (root@WangHaiTao) (gcc version 3.4.2) #1 Wed Sep 2 10:13:53 CST 2009

The router's LIB dir contains:

ld-uClibc.so.0 libc.so.0 libcrypt.so.0 libcrypto.so.0.9.7 libdl.so.0 libm.so.0 libnvram.so libpsi.so libpsixml.so libresolv.so.0 libssl.so.0.9.7 libutil.so.0 libwlbcmcrypto.so libwlbcmshared.so libwlctl.so modules

Toolchain info: (on the host WIN 7 system)

C:\code>mips-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=mips-linux-gnu-gcc
COLLECT_LTO_WRAPPER=f:/program files/codesourcery/sourcery_codebench_lite_for_mi
ps_gnu_linux/bin/../libexec/gcc/mips-linux-gnu/4.6.3/lto-wrapper.exe
Target: mips-linux-gnu
Configured with: /scratch/cmoore/2012.03-63-linux-lite/src/gcc-4.6-2012.03/confi
gure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=mips-linux-gnu --ena
ble-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with
-arch-32=mips32r2 --with-arch-64=mips64r2 --with-float=hard --with-mips-plt --en
able-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-t
emps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2012 -D__CS_SOURCERYGXX_MIN__=3 -D
__CS_SOURCERYGXX_REV__=63 %{O2:%{!fno-remove-local-statics: -fremove-local-stati
cs}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}
}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu -
-enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2012.03-63' --wi
th-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=
/opt/codesourcery --with-sysroot=/opt/codesourcery/mips-linux-gnu/libc --with-bu
ild-sysroot=/scratch/cmoore/2012.03-63-linux-lite/install/host-i686-mingw32/mips
-linux-gnu/libc --with-libiconv-prefix=/scratch/cmoore/2012.03-63-linux-lite/obj
/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --with-gmp=/scratch/cmoore
/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr
--with-mpfr=/scratch/cmoore/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-
linux-gnu-i686-mingw32/usr --with-mpc=/scratch/cmoore/2012.03-63-linux-lite/obj/
host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --with-ppl=/scratch/cmoore/
2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr -
-with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with
-cloog=/scratch/cmoore/2012.03-63-linux-lite/obj/host-libs-2012.03-63-mips-linux
-gnu-i686-mingw32/usr --with-libelf=/scratch/cmoore/2012.03-63-linux-lite/obj/ho
st-libs-2012.03-63-mips-linux-gnu-i686-mingw32/usr --disable-libgomp --enable-po
ison-system-directories --with-build-time-tools=/scratch/cmoore/2012.03-63-linux
-lite/obj/tools-i686-pc-linux-gnu-2012.03-63-mips-linux-gnu-i686-mingw32/mips-li
nux-gnu/bin --with-build-time-tools=/scratch/cmoore/2012.03-63-linux-lite/obj/to
ols-i686-pc-linux-gnu-2012.03-63-mips-linux-gnu-i686-mingw32/mips-linux-gnu/bin
Thread model: posix
gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-63)



I tried the following compile parameters:

  1. mips-linux-gnu-gcc -mips32 -muclibc -o factorial factorial.c

When I ran the output binary on the MIPS box, it just printed "can't load library 'libgcc_s.so.1' ".

  1. mips-linux-gnu-gcc -muclibc -mips32 -static-libgcc -s -o factorial factorial.c

When I run its output, it prints 'sigsegv'.

What is wrong here? What compiler parameter should I enter? Please help me.

UPDATE: Added more info.

share|improve this question
    
are the libraries in 'LIB dir' located on your machine, on the router or on both? –  user1146332 Aug 29 '12 at 17:45
    
that dir is located on the router. –  0xakhil Aug 30 '12 at 19:02
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.