7

I have seen several ways to do this (and so far I havent tried a couple but I want to isolate this one for ease)

There is supposed to be a way to do this VIA gcc and I would prefer this i just keep hitting walls.

I am using debian7 and can use what ever other flavor out there (I am for the time being wanting to avoid qemu casue I want something smaller scale.) I am following this example found here.

http://moozing.wordpress.com/2011/04/05/cross-compile-in-debian/

I have been able to do everything and during part of this I had to install libgmp3c2-dummy_1.0_all.deb for ti to continue

just now I need to compile and all I am compiling is a simple hello world script however , upon compiling I can't cause libgmp.so.3 is not in the /usr/lib/ dir however, there is one in /usr/lib/mips-linux-gnu-gcc folder I thought I'd copy it over to see if get it to compile and I get that this elf file is encoded in big-endian which makes sense. but what is it that I am missing to compile this file??

and I tried to compile the thing as big endian I think that either that I have confusion from the libraries or that I need a differnt libgmp.so.3 ..

also I tried apt-get install libgmp-dev libgmp3-dev too.

Thank you for helping helping if you can! :) and if you know of a simple way to do this that wont take a bunch of space on the my machine then I am open but I would like to try with GCC and using the tool chain.

Thanks!

LUser
  • 1,127
  • 4
  • 23
  • 39
  • possible duplicate of [Is there a way to use gcc to convert C to MIPS?](http://stackoverflow.com/questions/4175450/is-there-a-way-to-use-gcc-to-convert-c-to-mips) – user2284570 Jul 06 '14 at 23:35
  • It might be a duplicate as for information. However, in terms of giving the most compete answer, the one provided here will show others how to do this. Also, using Qemu for the whole process is bulky and not something that everyone can pick up. – LUser Jul 08 '14 at 05:52
  • Duplicate, because the same answers apply to both questions. – user2284570 Jul 08 '14 at 10:25

3 Answers3

9

Well I managed to compile MIPS in Debian. Edit I want to improve this answer for ease for use to others...

    1. deb http://www.emdebian.org/debian stable main to /etc/apt/sources.list 

    2. apt-get update.

    3. install libgmp3c2 from https://packages.debian.org/squeeze/libgmp3c2

    4. apt-get install gcc-4.3-mips-linux-gnu libgmp3c2-mips-cross this worked

then just mips-linux-gnu-gcc file.c -o executable

That's it.

PS if you're working on Routers.... use the -static option when compiling. So in the end it looked like

mips-linux-gnu-gcc -EB -march=34kc -static test.c -o test

If you have problems with a keyring public key not being recognized, use the emdebian-archive-keyring package which can be installed using apt.

linuxhackerman
  • 300
  • 2
  • 8
LUser
  • 1,127
  • 4
  • 23
  • 39
  • I don't like the Edit above because its not as explicit as my answer was. For anyone that needs the explicit answer for looking for the emdebian-archive-keyring you can look here. http://ftp.us.debian.org/debian/pool/main/e/emdebian-archive-keyring/emdebian-archive-keyring_2.0.3_all.deb – LUser Jun 20 '16 at 20:56
2

Why not just install the free Mentor/Codesourcery gcc MIPS cross compiler, instead of trying to build one from scratch?

When you have a MIPS cross compiler installed, you should install MIPS libraries in the appropriate directory for the cross compiler, and not in the /usr/lib directory for your host linux installation. You cannot use apt-get to attempt to install MIPS libraries, since that tool can only install libraries for your host linux installation.

markgz
  • 6,054
  • 1
  • 19
  • 41
0

You can reference this post Setting up cross-compiler for MIPS-I version 1 since it seems to be the simplest solution to your problem since you want to simply cross-compile for MIPS (reference his answer to the question as well). Note I haven't actually tested it.

I have built GCC to show the source in MIPS assembly from my ARM processor, but I can't seem to find the guide anymore. But you may want to look into building gcc for cross-compiling as well. I'll update this post in a few days since this has intrigued me to write a simple HOWTO set up a MIPS cross-compiler.

Community
  • 1
  • 1
wazy
  • 1,065
  • 1
  • 10
  • 23
  • Well I managed to compile MIPS. I added this 1. 'http://www.emdebian.org/debian/ stable main' to /etc/apt/sources.list 2. apt-get update 3.install libgmp3c2 http://packages.debian.org/squeeze/libgmp3c2 4. apt-get install gcc-4.3-mips-linux-gnu libgmp3c2-mips-cross this worked – LUser Jun 11 '13 at 16:52
  • BUT I when ever I run my program (is just a simple helloworld.c)I get line 1: syntax error: word unexpected (expecting")") this makes me think that I left our a parentheses .. but I haven't.. the target FS might br readonly... would I get this error? – LUser Jun 11 '13 at 16:55
  • I did a ls -alrth and I get -rwxr-xr-x for each of these this would make me thing I could execute these... although ./file returns file cant file:not found.... weird eh? – LUser Jun 11 '13 at 17:02