LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   MIPS cross compiling (https://www.linuxquestions.org/questions/programming-9/mips-cross-compiling-4175644947/)

circus78 12-25-2018 11:03 AM

MIPS cross compiling
 
Hi,
I need to compile a software for MIPS architecture.
I followed this tutorial:

https://www.linux-mips.org/wiki/Toolchains


to build my own toolchain, and everything went ok.

I am trying to compile a simple "hello world", just to test, and I receive:

Code:

# mips-unknown-linux-gnu-gcc hello.c -o hellomips
hello.c:1:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                  ^
compilation terminated.

Code:

# find . -name stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/fixincludes/tests/base/rtldef/stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/fixincludes/tests/base/stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/libssp/ssp/stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/libstdc++-v3/include/tr1/stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/libstdc++-v3/include/c_compatibility/stdio.h
./mips-unknown-linux-gnu-toolchain/gcc-4.8.2/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h





hello.c's content:

Code:

#include <stdio.h>
int main()
{
  // printf() displays the string inside quotation
  printf("Hello, World!");
  return 0;
}

What am I missing?

Thank yoU!

pan64 12-25-2018 12:24 PM

probably: https://wiki.osdev.org/GCC_Cross-Com...e_new_Compiler

circus78 12-25-2018 01:04 PM

Hi pan64, I already configured PATH accordingly:

Code:

# echo $PATH
/opt/cross/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/root/bin


(mips-unknown-linux-gnu-gcc resides in /opt/cross/bin)

Are you referring to a different issue?

Thankyou

pan64 12-26-2018 02:09 AM

This is how you need to continue:
Quote:

Now you have a "naked" cross-compiler. It does not have access to a C library or C runtime yet, so you cannot use any of the standard includes or create runnable binaries.
Probably this helps to go further: http://www.fabriziodini.eu/posts/cro...pile_tutorial/

circus78 12-26-2018 06:01 AM

Hi pan64, thank you very much, your last link is even more detailed.
Just one last doubt: how can I determine in my target system is MIPS little endian or big endian?

pan64 12-26-2018 06:53 AM

probably this helps: https://www.linux-mips.org/wiki/Endianness
but actually I would write a simple check program.

circus78 12-26-2018 08:50 AM

Hi, I guess I would first need to know which architecture is before writing a check program, isn't? :)
I tried to copy a binary executable from target system (mips o mipsel, I don't know) to my Linux machine.
File shows this:

Code:

$ file dmesg
dmesg: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, stripped

Code:

$ hexdump dmesg  |head
0000000 457f 464c 0201 0001 0000 0000 0000 0000
0000010 0200 0800 0000 0100 4000 b04b 0000 3400
0000020 0600 94fb 0070 0510 3400 2000 0800 2800
0000030 1e00 1d00 0000 0600 0000 3400 4000 3400
0000040 4000 3400 0000 0001 0000 0001 0000 0500
0000050 0000 0400 0000 0300 0000 3401 4000 3401
0000060 4000 3401 0000 1400 0000 1400 0000 0400
0000070 0000 0100 0000 0100 0000 0000 4000 0000
0000080 4000 0000 0600 00da 0600 00da 0000 0500
0000090 0100 0000 0000 0100 0600 00e0 4700 00e0


so I assume is 32bit, but I don't know how to distinguish between big endian and little endian.

pan64 12-26-2018 09:41 AM

https://stackoverflow.com/questions/...-vs-big-endian

https://stackoverflow.com/questions/...-little-endian


All times are GMT -5. The time now is 08:05 AM.