1

I am trying to compile a piece of code on my Linux system (x86_64) for MIPS big endian architecture.

Basically I followed this URL: https://www.linux-mips.org/wiki/Toolchains

to get my own tool chain.

I tried to compile software, configure phase is OK:

./configure --target=mips-unknown-linux-gnu --host=mips-unknown-linux-gnu CC=/opt/cross/bin/mips-unknown-linux-gnu-gcc  --prefix=/opt/mycode

I get this error just after "make":

# make
make  all-recursive
make[1]: Entering directory `/usr/local/src/code2.0.9'
Making all in compat
make[2]: Entering directory `/usr/local/src/code2.0.9/compat'
/opt/cross/bin/mips-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I..          -I../include -I../include  -Wall -O2  -MT Thread.o -MD -MP -MF     .deps/Thread.Tpo -c -o Thread.o Thread.c
In file included from Thread.c:71:0:
../include/headers.h:78:20: fatal error: stdlib.h: No such file or      directory
 #include <stdlib.h>

How can I fix this issue? Thank you

hap78
  • 29
  • 1
  • 3
  • The `` header file is part of the C standard library, it should be available for all C implementations. If you don't have it then your cross-compilation environment is not properly installed. Have you e.g. installed a C standard library, cross-compiled for your target? – Some programmer dude Aug 02 '19 at 22:29
  • 2
    And a note about "target" and "host"... The "target" is the platform you're building *for*, the "host" is the platform you're building *on*. If you're on an x86_64 Linux system, then that's the host. – Some programmer dude Aug 02 '19 at 22:32
  • Do you have `stdlib.h` somehwere inside `/opt/cross` directory? – KamilCuk Aug 02 '19 at 23:00
  • Hi Kamil, no, I don't! – hap78 Aug 03 '19 at 14:26
  • root@server:/opt/cross# find . -name stdlib.h returns nothing – hap78 Aug 03 '19 at 14:27

2 Answers2

1

I finally solved with buildroot. I set target mips and build my toolchain. After that, I used this command to compile source:

./configure --enable-static --disable-shared --target=mips-buildroot-linux-gnu --host=mips-buildroot-linux-gnu CC=/home/myuser/buildroot-2019.05.1/output/host/bin/mips-linux-gcc --with-openssl=no  --disable-profiling

All went ok

hap78
  • 29
  • 1
  • 3
0

I think host command is not correct.

try this,

./configure --target=mips-unknown-linux-gnu --host=linux CC=/opt/cross/bin/mips-unknown-linux-gnu-gcc --prefix=/opt/mycode

  • I got error: "checking host system type... Invalid configuration `linux': machine `linux' not recognized configure: error: /bin/sh ./config.sub linux failed " – hap78 Aug 03 '19 at 14:29
  • I tried with ./configure --target=mips-unknown-linux-gnu --host=x86_64-unknown-linux-gnu CC=/opt/cross/bin/mips-unknown-linux-gnu-gcc --prefix=/opt/iperf-2.0.9/ but at the end (make) I got same error about stdlib.h missing – hap78 Aug 03 '19 at 14:29