LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-25-2018, 11:03 AM   #1
circus78
Member
 
Registered: Dec 2011
Posts: 265

Rep: Reputation: Disabled
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!
 
Old 12-25-2018, 12:24 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,236

Rep: Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452
probably: https://wiki.osdev.org/GCC_Cross-Com...e_new_Compiler
 
Old 12-25-2018, 01:04 PM   #3
circus78
Member
 
Registered: Dec 2011
Posts: 265

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-26-2018, 02:09 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,236

Rep: Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452
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/

Last edited by pan64; 12-26-2018 at 02:14 AM.
 
2 members found this post helpful.
Old 12-26-2018, 06:01 AM   #5
circus78
Member
 
Registered: Dec 2011
Posts: 265

Original Poster
Rep: Reputation: Disabled
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?
 
Old 12-26-2018, 06:53 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,236

Rep: Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452
probably this helps: https://www.linux-mips.org/wiki/Endianness
but actually I would write a simple check program.
 
1 members found this post helpful.
Old 12-26-2018, 08:50 AM   #7
circus78
Member
 
Registered: Dec 2011
Posts: 265

Original Poster
Rep: Reputation: Disabled
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.
 
Old 12-26-2018, 09:41 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,236

Rep: Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452Reputation: 5452
https://stackoverflow.com/questions/...-vs-big-endian

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

Last edited by pan64; 12-26-2018 at 09:43 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cross compiling mips: Linker error: cannot find entry symbol __start; Vido Programming 0 03-19-2017 08:54 PM
Cross-compiling util-linux 2.22 for MIPS dilbert_uk Linux - Software 2 01-29-2013 05:25 AM
How to make cross compilation toolchain for mips architecture kennithwang Linux - Embedded & Single-board computer 3 10-20-2007 08:03 AM
LXer: CodeSourcery Joins MIPS(R) Alliance Program and Delivers GNU/Linux Prelinker for MIPS-Based(TM) Processors LXer Syndicated Linux News 0 10-31-2006 07:54 PM
How to cross-compile X window for mips! whutxuan Programming 4 09-26-2005 02:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration