SRL Archive - Computer Help and Tutorials

Crossdev - Cross compiling


Wizzup?

2011-02-16 16:29:38

OK, so I had to get myself a cross toolkit to compile SMART for Windows x86 - I know others have done it and it's pretty simple on Debian/Ubuntu (You emerge some mingw package iirc, I did it on ubuntu before)

Anyway, I don't use Debian; I mainly use Gentoo, which has crossdev. And it's awesome.

Really, I never expected it to be that nice. I still haven't toyed around with it that much, but still. I just wanted to let some of you guys know.

Usage is simple; http://www.gentoo.org/proj/en/base/embedded/cross-development.xml

You install it; set up an overlay (basically just create a folder and set and env variably in /etc/make.conf) and run crossdev i686-mingw32 (we can also use other architectures - I am not 100% sure if they will all work, but I just want x86+windows now)

It will then just build the full tool chain - and it works too. Admittedly I haven't toyed around with it that much yet, but it seems to work fine…

I realise most of you won't care, but perhaps the ones who do actually have to do quite some cross compiling will care. (mopar, perhaps) :)

# crossdev i686-mingw32
--------------------------------------------------------------------------------
* crossdev version: 20100814
* Host Portage ARCH: amd64
* Target Portage ARCH: x86
* Target System: i686-mingw32
* Stage: 4 (C/C++ compiler)

* binutils: binutils-[latest]
* gcc: gcc-[latest]
* headers: w32api-[latest]
* libc: mingw-runtime-[latest]

* PORTDIR_OVERLAY: /usr/local/overlays/crossdev
* PORT_LOGDIR: /var/log/portage
* PKGDIR: /usr/portage/packages/cross/i686-mingw32
* PORTAGE_TMPDIR: /var/tmp/cross/i686-mingw32
_ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ -
* Forcing the latest versions of {binutils,gcc}-config/gnuconfig ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-binutils.log
* Emerging cross-binutils ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-w32api-quick.log
* Emerging cross-w32api-quick ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-mingw-runtime-headers.log
* Emerging cross-mingw-runtime-headers ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-gcc-stage1.log
* Emerging cross-gcc-stage1 ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-w32api.log
* Emerging cross-w32api ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-mingw-runtime.log
* Emerging cross-mingw-runtime ... [ ok ]
* Log: /var/log/portage/cross-i686-mingw32-gcc-stage2.log
* Emerging cross-gcc-stage2 ... [ ok ]

$ vim Makefile  # Had to change the cross compiler name.
$ make windows
Compiling Main.cpp
Compiling Color.cpp
Compiling Java Classes...
src/smart/Client.java:66: warning: sun.applet.AppletClassLoader is internal proprietary API and may be removed in a future release
import sun.applet.AppletClassLoader;
^
src/smart/Client.java:531: warning: sun.applet.AppletClassLoader is internal proprietary API and may be removed in a future release
thisLoader = AppletClassLoader.newInstance(new URL[] { clientConnection.getJarFileURL() });
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 warnings
Encoding Java classes...
+build/java/java/awt/Canvas$AccessibleAWTCanvas.class
+build/java/java/awt/Canvas.class
+build/java/smart/EventRedirect.class
+build/java/smart/Client.class
+build/java/smart/Client$3.class
+build/java/smart/ClientStub.class
+build/java/smart/EventNazi.class
+build/java/smart/EventNazi$KeySender.class
+build/java/smart/Client$2.class
+build/java/smart/UnblockedEvent.class
+build/java/smart/BlockingEventQueue.class
+build/java/smart/Client$1.class
+build/java/smart/Client$4.class
Compiling Classloader.cpp
Compiling Input.cpp
Compiling Reflection.cpp
Compiling JVM.cpp
Compiling Smart.cpp
Linking object files...
Finished Building the Windows SMART distribution

I'm going to try it on my ARM sheevaplug soon, I think.

E: It did pick GCC 4.5 though, which is as far as I know not extremely well tested.

Smartzkid

2011-02-16 18:24:44

I'm interested to see if it will run on ARM!

moparisthebest

2011-03-09 00:11:52

What about a Mac OSX cross compiler? I recently set one of these up for a C++ project I am working on, and it was a pain in the ass. If that has built in functionality for that I might have to switch?

Wizzup?

2011-03-09 04:57:34

From: moparisthebest
What about a Mac OSX cross compiler? I recently set one of these up for a C++ project I am working on, and it was a pain in the ass. If that has built in functionality for that I might have to switch?


It should be possible, although with a quick look I mainly found a target to mac powerpc, not x86. But yeah, it should work. I can give it a go later.

From: Smartzkid
I'm interested to see if it will run on ARM!


Do you mean SMART?

Smartzkid

2011-03-09 12:45:28

From: Wizzup?
It should be possible, although with a quick look I mainly found a target to mac powerpc, not x86. But yeah, it should work. I can give it a go later.



Do you mean SMART?


Mhmm. IIRC my clothes drier runs on an ARM based micro ;)

Wizzup?

2011-03-09 13:16:52

From: Smartzkid
Mhmm. IIRC my clothes drier runs on an ARM based micro ;)


I have tested it yet due to lack of ARM java compilers on my system. I'll have to play with a bit more and then I can compile SMART. (Actually, I think I can just copy over the .class files from another arch since it's all bytecode)

AFAIK it should work, since there's no platform specific code in SMART anymore.

moparisthebest

2011-03-10 18:10:43

I should have posted this before, but just for reference, I used this to set up a Mac OSX cross compiler under Linux:

http://www.sandroid.org/imcross/

It's really 2 cross compilers, as it's for ppc and i386 mac.

If you could do this on Gentoo with the built-in tools, I might have to switch. :)

Wizzup?

2011-06-02 06:07:13

I'm not sure if Gentoo supports all those targets, but if there is one distro specialised in compiling then it is Gentoo. ;)