title: Problems installing a mips cross compiler
body: <p>I´m doing my master thesis and I´m having problems configuring the cross compiler. I´ve read lots of articles, faq, tutorial, etc.., but I still think I´m missing something, maybe very stupid and basilar, but without that I can´t have a clear vision of everything and I can´t make it all work…so please feel free to explain me everything. Let´s go to the problem.</p>
  
  <p>I´m using SoClib to design a NoC with many MIPS and many RAMs and I want to load different applications in every RAM, to make every MIPS read from only one RAM. I managed to do that using very simple applications (like hello word with interrupts…) so now I was trying to realize a JPEG decoder to use in a more intense way the MIPS. The problem is that the cross compiler I´m using can´t find the basic stdio functions and so cannot compile the application for the mips. So basically I didn´t managed to install a working full cross compiler.</p>
  
  <p>1) Let´s start with the cross compiler installed with SoClib:
  Here there is the guide I´ve followed to install it: <a href="http://www.soclib.fr/trac/dev/wiki/CrossCompiler" rel="nofollow">http://www.soclib.fr/trac/dev/wiki/CrossCompiler</a>
  Now from what I´ve read this is not a full cross compiler. I´ve only installed a first stage gcc that can generate elf code for the mips but that can´t use any C function. With that one, I should compile a C library to create a new cross compiler. So it´s normal that it is not working, although that doesn´t answer to the question: why “Hello world” was working if it uses a printf and includes stdio.h? The answer should be that I´ve seen that SoClib has his header stdio.h with very few function realized (printf is there) so I can´t use the standard C library with that compiler. </p>
  
  <p>2) Because of that I´ve decided to install a full cross compiler and I´ve read so many guides that I will only post the two I´ve used in practice:
  <a href="http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf" rel="nofollow">http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf</a>  from page 108 (before explains the problems with cross compiling)
  It uses EGLIBC. The only difference is that I´ve used as target “mipsel-elf”. If I´ve understood correctly, this method requires a 3 stage cross compiler, because eglibc can´t be fully compiled with the first stage cross compiler. Now the problem is that I can´t succeed in installing eglibc with the first stage cross compiler (it fails at page 122). I´have attached the log. I think problems starts when it says: “mipsel-elf-gcc: error: unrecognized option ´-V´” and “mipsel-elf-gcc: fatal error: no input files compilation terminated”. Seems that I´ve some problem with the compiler and all finishes with an unsupported platform…but it should work because I´ve copied the eglibc/ports directory like the guide says…</p>
  
  <p>3) I´ve tried another guide that uses newlib instead of eglibc:
  <a href="http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf">http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf</a>
  This guide creates only a 2 stage cross compiler. I think it´s because newlib can be fully compiled with the first stage compiler…am I right? Anyway I get the same problem. I can´t compile newlib and I get similar errors (log attached).</p>
  
  <p>So that´s my problem and here I put some doubt I´ve had trying to resolve it.</p>
  
  <p>4) Can the problem be the target=mipsel-elf? I know from the gnu documentation that the name to configure gnu should be: cpu-manufacturer-os (or cpu-manufacturer-kernel-os) but I´ve read that mipsel-elf is accepted. The elf should be because I don´t want to load an OS on my NoC platform and here the second doubt…</p>
  
  <p>5) Can the problem be the OS thing? The guides uses linux kernel headers…maybe with a mipsel-elf target I shouldn´t configure binutils –with-sysroot? But sounds me strange…what should change?</p>
  
  <p>6) Yet another probably stupid question. The stdio and generally C functions, doesn´t need an OS right? Because all these problems are making me doubt on the basics…so I should be able to run a JPEG decoding C application with a mipsel-elf cross compiler right?</p>
  
  <p>Every consideration, advice and help will be appreciated. If you have some documents about these arguments please let me know, I would like to learn and become more confident in this field.
  Thanks</p>
  
  <p>eglibc log:</p>
  
  <pre><code>configure:2426: $? = 0
  configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v &gt;&amp;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 &gt;&amp;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 &gt;&amp;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 &gt;&amp;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 &gt;&amp;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 &gt;&amp;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 &lt;stdarg.h&gt;
  | #include &lt;stdio.h&gt;
  | #include &lt;sys/types.h&gt;
  | #include &lt;sys/stat.h&gt;
  | /* 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 &gt;&amp;5
  mipsel-elf-gcc: error: unrecognized
  </code></pre>
  
  <p>option '-qlanglvl=extc89'
  configure:2809: $? = 1</p>
  
  <p>NEWLIB log</p>
  
  <pre><code>configure:4049: $? = 0
  configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v &gt;&amp;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 &gt;&amp;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 &gt;&amp;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  &gt;&amp;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
  </code></pre>