安装mips交叉编译器的问题

时间:2012-01-06 13:04:48

标签: cygwin mips cross-compiling newlib

我正在做我的硕士论文,我在配置交叉编译器时遇到了问题。我读过很多文章,常见问题,教程等等,但我仍然认为我错过了一些东西,也许是非常愚蠢和卑鄙的,但如果没有这个,我就无法对所有事情有清晰的认识,我无法做到让它全部工作......所以请随时向我解释一切。我们来解决问题。

我正在使用SoClib来设计具有许多MIPS和许多RAM的NoC,并且我想在每个RAM中加载不同的应用程序,以便从一个RAM中读取每个MIPS。我设法使用非常简单的应用程序(比如hello word with interrupts ...)这样做,所以现在我试图实现一个JPEG解码器以更强烈的方式使用MIPS。问题是我使用的交叉编译器无法找到基本的stdio函数,因此无法为mips编译应用程序。所以基本上我没有设法安装一个有效的完整交叉编译器。

1)让我们从使用SoClib安装的交叉编译器开始: 这里有我遵循的指南安装它:http://www.soclib.fr/trac/dev/wiki/CrossCompiler 从我读过的内容来看,这不是一个完整的交叉编译器。我只安装了第一阶段gcc,可以为mips生成elf代码,但不能使用任何C函数。有了这个,我应该编译一个C库来创建一个新的交叉编译器。所以它不起作用是正常的,虽然它没有回答这个问题:如果它使用printf并包含stdio.h,为什么“Hello world”正在工作?答案应该是我已经看到SoClib的头文件stdio.h实现了很少的功能(printf就在那里)所以我不能使用标准的C库和那个编译器。

2)因为我已经决定安装一个完整的交叉编译器,并且我阅读了很多指南,我将只发布我在实践中使用的两个: 来自第108页的http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf(之前解释了交叉编译的问题) 它使用EGLIBC。唯一的区别是我用作目标“mipsel-elf”。如果我理解正确,这个方法需要一个3阶段交叉编译器,因为eglibc不能用第一阶段交叉编译器完全编译。现在问题是我无法使用第一阶段交叉编译器成功安装eglibc(它在第122页失败)。我已经附上了日志。我认为问题一开始就说:“mipsel-elf-gcc:错误:无法识别的选项'-V'”和“mipsel-elf-gcc:致命错误:没有输入文件编译终止”。似乎我在编译器方面遇到了一些问题,并且所有问题都在不受支持的平台上完成......但是它应该可以工作,因为我已经复制了eglibc / ports目录,就像指南说的那样......

3)我尝试过使用newlib而不是eglibc的另一个指南: http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf 本指南仅创建一个2阶段交叉编译器。我想是因为newlib可以用第一阶段编译器完全编译......我是对的吗?无论如何,我得到了同样的问题。我无法编译newlib,我得到类似的错误(附加日志)。

所以这就是我的问题,在这里我有点怀疑我试图解决它。

4)问题可能是target = mipsel-elf吗?我从gnu文档中知道配置gnu的名称应该是:cpu-manufacturer-os(或cpu-manufacturer-kernel-os),但我读过mipsel-elf被接受了。精灵应该是因为我不想在我的NoC平台上加载操作系统,这是第二个疑问......

5)问题可能是操作系统的问题吗?指南使用linux内核头文件......可能有一个mipsel-elf目标我不应该配置binutils -with-sysroot?但听起来很奇怪......应该改变什么呢?

6)另一个可能是愚蠢的问题。 stdio和一般的C函数,不需要操作系统吗?因为所有这些问题让我对基础知识产生怀疑......所以我应该能够使用mipsel-elf交叉编译器运行JPEG解码C应用程序吗?

我们将非常感谢您的每一个考虑,建议和帮助。如果你有关于这些论点的一些文件,请告诉我,我想学习并在这个领域变得更有信心。 感谢

eglibc log:

configure:2426: $? = 0
configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC) 
configure:2437: $? = 0
configure:2444: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:2448: $? = 1
configure:2452: checking for suffix of object files
configure:2478: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c   conftest.c >&5
configure:2482: $? = 0
configure:2507: result: o
configure:2511: checking whether we are using the GNU C compiler
configure:2540: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c   conftest.c >&5
configure:2547: $? = 0
configure:2564: result: yes
configure:2573: checking whether /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc accepts -g
configure:2603: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g  conftest.c >&5
configure:2610: $? = 0
configure:2711: result: yes
configure:2728: checking for /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc option to accept ISO C89
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc  -c -g -O2  conftest.c >&5
conftest.c:9:19: fatal error: stdio.h: No such file or directory
compilation terminated.
configure:2809: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
| 
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
| 
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
|    inside strings and character constants.  */
| #define FOO(x) 'x'
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
| 
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qlanglvl=extc89 -c -g -O2  conftest.c >&5
mipsel-elf-gcc: error: unrecognized

选项'-qlanglvl = extc89' configure:2809:$? = 1

NEWLIB日志

configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC) 
configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qversion >&5
mipsel-elf-gcc: error: unrecognized option '-qversion'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4069: checking for C compiler default output file name
configure:4091: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc    conftest.c  >&5
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crti.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtbegin.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtend.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
configure:4095: $? = 1
configure:4132: result: 
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:4138: error: in `/home/bertone/programmazione/crosscompiler/mips/build/newlib':
configure:4142: error: C compiler cannot create executables

2 个答案:

答案 0 :(得分:0)

为什么不直接为MIPS下载免费的预建GCC Codesourcery Lite交叉编译工具链?

  

6)stdio和一般的C函数,不需要操作系统吗?

通常,libc将stdio调用转换为对底层操作系统的系统调用,因此您需要有一个用于stdio的操作系统才能工作。如果JPEG解码器应用程序不调用需要操作系统的任何内容,那么它将正常工作,但您需要创建一种方法,将来自NoC的每个CPU的结果传递到外部世界。

答案 1 :(得分:0)

首先,关闭,你需要这些stdio功能吗?

可以替换这些stdio功能吗?例如,你真的需要一个printf(一个更痛苦的),或者你可能愿意用其他东西替换那些,也许是一个很容易实现的string_display()和hex_display()函数和库和系统无关。

这些文件I / O功能是什么?我似乎记得一个流行的开源jpeg解码器想要为你做文件I / O.实现一个fopen()(只返回任何有效的东西),一个fread,它只是跟踪二进制中包含的一些const数据中的指针,并执行mem copy和fwrite,真的有多难deal跟踪数组中的指针并执行mem copy。

我已经嵌入了jpeg解码器,mp3等进行系统调用,两者都使用了newlib(),这使得它变得更容易但是现在用构建交叉编译器非常痛苦,并且还用系统调用替换系统调用不同的功能或通过实现这些功能的模拟。

如果您使用免费的codesourcery lite(现在称为codebench或其他东西,因为它是指导图形而不是代码源)并用模拟的系统调用替换系统调用,您就不必再乱用编译器了。

我有一些非常简单的mips代码,但也有一些用于构建我正在讨论的gnu交叉编译器的指令(如果你没有使用系统调用,C库调用,gcc库调用,因为你实现了,效果很好你自己的一切)。

https://github.com/dwelch67/pic32_samples

这与我正在构建的完整交叉编译器相差不远。 Gcc / gnu不是那么稳定,你可以从任何版本交叉编译任何版本并让它工作,同样,使用任何版本的任何主机上的任何版本的任何目标的交叉编译器都不稳定。有时,目标版本的binutils + gcc + newlib恰好可以正常工作。例如,在这段时间/历史中,无论是在Linux上还是在windows上使用mingw都可以。

http://www.dwelch.com/ipod/gccarm.txt

但除非您使用虚拟机(vmware等)并使用足够旧的构建系统在其上安装旧的Linux,否则您将无法构建上述内容。

不久前,也许这仍然适用于现代系统。这是为了手臂,但也许它也适用于mips。

http://www.cowlark.com/2009-07-04-building-gcc/

我不认为我有任何代码发布的mp3和zlib和jpeg库没有系统调用或模拟系统调用我可以发布它们的地方。如果你想使用zlib作为性能测试或其他东西,一次压缩或解压缩或两者兼而有之,mallocs很容易实现,比如zlib,不是通用的东西,而是带有数据和数据输出的受控测试环境。同样适用于其他受控环境jpeg编码或解码,mp3编码或解码(它们是有损的,因此您无法比较输入和输出必须验证系统产生正确的结果,校验和或crc很容易与已知的良好系统进行比较/结果)。

如果您检查我在nulllib中取消并稍后替换的文件,您可以看到newlib将stdio调用放入哪个文件,然后您将实现这些函数中的每一个。我有几个旧网站,至少有dhrystone的例子,几乎只是想要一个printf http://www.dwelch.com/ipod/ http://www.dwelch.com/gba/dhry.htm,你可以看到我用newlib做了什么函数,大多数只是通过返回一个传递值来扼杀它们,并弄清楚newlib想要输出到stdout时的作用。

或者用替代函数替换某些stdio调用的示例,从而导致仍然有效的东西。不是说它很漂亮,但你可以玩游戏。 https://github.com/dwelch67/stm32f4d/blob/master/adventure/

基本上我正在阅读的是你已经确定了一个问题,但只追求一条路径,在编译器方面解决它。当你可以通过创建一个抽象层或垫片来解决它,或者通过完全删除有问题的代码或用较少的冒犯性代码替换它。如果你看一下冒险的源代码以及类似时代的游戏帝国等,即使是小型c编译器和其他代码已被移植了很多次,你可以看到他们确实这样做了,他们通过制作非解决问题语言,大部分代码中的非系统特定调用,然后最后一英里是在一个或几个特定于系统的位置实现这些调用。即使您要获得gcc + newlib或gcc + glibc交叉编译器,您仍然必须使用自己的默认stdio替换为操作系统层。 (这也是编译器的一面,一个庞大的庞大抽象层,glibc,newlib等,你仍然需要实现后端)。