编译基于MIPS的代码库工具链的参数? [英] Compile parameters for MIPS based codesourcery toolchain?

查看:975
本文介绍了编译基于MIPS的代码库工具链的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的WIN 7机器上安装codesourcery交叉编译工具链为mips32架构。我想先为基于MIPS32的路由器编译一个简单的阶乘二进制。从互联网上的一点搜索,我发现它是基于MIPS32大端序。

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

路由器的LIB目录包含:

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 libwlbcmcrso.so libwlbcmcrypto.so libwlbcmshared.so libwlctl.so modules

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

工具链信息:主机WIN 7系统)

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

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

当我在MIPS盒子上运行输出二进制文件时, 'libgcc_s.so.1'。

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

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

当我运行它的输出时,它输出'sigsegv '。

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

这里有什么问题?我应该输入什么编译器参数?请帮助我。

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

推荐答案

在文件系统上有libgcc_s.so.1吗?如果没有,工具链将有一个文件夹复制到文件系统。去做。

Do you have libgcc_s.so.1 on teh file system? If not, the toolchain will have a folder to copy onto the file system. Do that.

如果您这样做,请确保LD_LIBRARY_PATH设置正确。

If you do, ensure LD_LIBRARY_PATH is correctly set.

编辑:通用问题解决

创建可执行文件时,链接到库。这些库还必须存在于运行可执行文件的环境中。因此一般来说,在嵌入式系统中,事情必须匹配

When you create a executable, you link to libraries. Those libraries must also be present in the environment where you run the executable. Hence in general in a embedded system 3 things must match


  1. 内核头

  2. / li>
  3. 档案系统

这是他们之间的关系。

你的内核头文件最终以某种形式在你的程序中用作#include。因此,工具链使用的头文件必须与实际运行的头文件匹配,并且将存在于文件系统中。

Your kernel headers are used as #include in your program in some form finally. So what headers the toolchain uses must match the actual one running and will be present in the file system.

工具链将包含要链接的库,可以创建[认为libc和其他]。这些必须在您的文件系统的运行时环境中存在。

The toolchain will consist of libraries to link to, so that the executable can be created [think libc and others]. These must be the same present in your runtime environment which is your filesystem

工具链必须为您的内核创建一个可扩展的格式。可执行格式。

The toolchain must create a format agreable to your kernel. Executable format.

所以一般来说,如果你在文件系统中没有一个文件,而试图执行它应该来自一些sdk或你的工具链。
如果你在文件系统中有它,那么你可以指示你的工具链从那里使用它。

So in general if you don't have a file in your filesystem while trying to execute it should come from some sdk or your toolchain. If you have it in the filesystem then you can instruct your toolchain to use it from there.

一种方法来解决问题,如果你没有文件系统中的库由于某种原因是构建静态可执行文件。但你必须确定你知道你在做什么。

One way to get around the problem if you do not have the libraries in the filesystem for some reason is to build static executables. But you must be sure you know what you are doing.

编辑:你面临的具体问题
如果你的文件系统是只读的,那么你已经有一切它和一个sdk提供发展反对。如果你没有,你仍然可以开发通过让你的工具链使用库文件系统[think -I,-L]。

Specific issue you are facing If you filesystem is readonly then either you already have everything on it and a sdk is provided to develop against. If you dont have that you can still develop by getting your toolchain to use libraries from your filesystem [think -I, -L].

编辑2:
您的文件系统似乎是ucLibc。你的工具链似乎是针对libc构建的。有你的不匹配。

EDIT 2: Your file system seems to be a ucLibc one. Your toolchain seems to be built against a libc. There is your mismatch.

现在你似乎有一个只读文件系统,没有开发sdk。所以我不知道以下将工作。
您的工具链必须配置为仅使用文件系统中的文件,并配置为ucLibc。如果路由器人已经确保所有需要开发的文件在rilesystem中可用,它足够好。否则你需要他们的sdk。请参阅上述编辑说明。

Now you seem to have a read only file system with no development sdk. So I am not sure the following will work. Your toolchain has to be configured to use only the files from your filesystem and configured for ucLibc. If the router guys have made sure all files needed for development is available in the rilesystem its good enough. Else you need their sdk. See above edit for explanation.

这篇关于编译基于MIPS的代码库工具链的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆