Finally built a Cross Compiler for Windows -> Raspberry Pi
Here is the development environment I would recommend for Windows:
1. Eclipse IDE running on Windows with C++ plugin.
2. Share Raspberry Pi or QEmu network file system to windows using TAP bridge.
3. Build your source code in Eclipse IDE on network share.
4 Test built code on Raspberry Pi itself or QEmu if you do not have one yet.
Here are my working notes to build a Windows Cross Compiler for the Raspberry Pi
--------->8--------------------------->8---------------------------------->8---------------------------------
1.1 Install Tools
1. Install Cygwin with bison, flex, gettext, libtool, automake, libncurses5-dev, make, gcc-tools-epoch2-automake,
wget, gperf, patch, gcc-g++, git-svn.
2. Download and copy crosstool-ng-1.15.2 into the cygwin subdirectory.
3. $ tar jxf crosstool-ng-1.15.2.tar.bz2 – From the Cygwin prompt, extracts .tar.bz2 file from
http://crosstool-ng.org/hg/crosstool.ng
4. Run regedit and update the following setting to make cygwin case sensitive and then reboot:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive=0
5. $ cd crosstool-ng-1.15.2
6. $ export PATH=/opt/gcc-tools/bin:$PATH
7. $ ./configure --prefix=/opt/cross
1.2 Update crosstool-ng & eglibc to work with Cygwin
• When running make for crosstool-ng on cygwin, some errors regarding ncurses include and gettext
linking are produced: The code changes in the ‘crosstool-ng—cygwin.patch’ were made manually to
get crosstools-ng working with Cygwin.
• When running ct-ng build some egclibc rpc errors were produced. The code changes in ‘egibc 2.12 cygwin patch’
were made manually to eglibc 2.12 working with a Cygwin host.
1.3 Making crosstool-ng
8. $ make
9. $ make install
10. $ export PATH=$PATH:/opt/cross/bin
1.4 Create Toolchain
11. Create a directory /myCross. Crosstool-ng will use this as a staging area and will contain your toolchain
configuration, downloaded files and build results. This directory is likely to use at least (2GB+) of space.
12. $ cd /myCross.
13. $ ct-ng menuconfig. The the ct-ng configuration menu should appear, make the following changes:
Menu
----
Paths and misc options | Try features marked as EXPERIMENTAL – Enable
| Change your Prefix directory to: /opt/cross/x-tools/${CT_TARGET}
Target options | Change the Target architecture to arm.
| Leave Endianness set to Little endian and Bitness set to 32-bit.
| Change Floating point to softfp (For Raspberry Pi/Debian Squeeze - Open GL ES Examples)
Operating System | Change Target OS to Linux
Binary Utilities | Change binutils version to 2.21.1a (latest non experimental).
C compiler | Show Linaro versions (EXPERIMENTAL) – Enable
| Set gcc version to linaro-4.6-2012.04 (EXPERIMENTAL) – ARM optimized compiler.
| Notes.
| Build failed to download the Linario version so I went back and set this option
| to vanilla gcc 4.6.3
| Make sure C library is set to eglibc and not uClibc or glibc.
| (eglibc is Embedded glibc which Debian switched to from glibc)
| C compiler Crosstool-ng doesn’t build a C++ compiler by default.
| Additional Supported languages -> C++ - Enable
| You should use arm-unknown-linux-gnueabi-g++ instead of the -gcc version for C++ source files.
Leave all other settings at their default values.
Exit the configuration tool and save your changes.
You may additionally want to set more specific architecture settings in your .config file as shown in the table below
CT_ARCH_CPU="arm1176jzf-s"
CT_ARCH_TUNE="arm1176jzf-s"
CT_ARCH_FLOAT_HW=y or CT_ARCH_FLOAT_SOFTFP=y
CT_ARCH_FLOAT="hard" or CT_ARCH_FLOAT="softfp"
14. $ cd /myCross – Make sure this is /myCross and not /cygdrive as /cygdrive is case insensitive by default.
15. $ ct-ng build - This will take some time.
Notes.
• Raspbery Pi displays the following version information: cat /proc/version: Linux version 3.1.9+ and
(Sourcery G++ Lite) gcc version 4.5.2
------------------- crosstool-ng—cygwin.patch ----------------------------
--- crosstool-ng-1.15.0_old/kconfig/Makefile 2012-04-30 16:54:20.000000000 -0400
+++ crosstool-ng-1.15.0/kconfig/Makefile 2012-05-08 11:10:24.950066100 -0400
@@ -35,20 +35,21 @@
conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ))
$(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS)
+conf: LDFLAGS += -lintl
# What's needed to build 'mconf'
mconf_SRC = mconf.c
mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC))
$(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
-mconf: LDFLAGS += $(NCURSES_LDFLAGS)
+mconf: LDFLAGS += -lintl $(NCURSES_LDFLAGS)
# What's needed to build 'nconf'
nconf_SRC = nconf.c nconf.gui.c
nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC))
nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC))
-$(nconf_OBJ) $(nconf_DEP): CFLAGS += $(INTL_CFLAGS)
-nconf: LDFLAGS += -lmenu -lpanel -lncurses
+$(nconf_OBJ) $(nconf_DEP): CFLAGS += -I/usr/include/ncurses/ $(INTL_CFLAGS)
+nconf: LDFLAGS += -lintl -lmenu -lpanel -lncurses
# Under Cygwin, we need to auto-import some libs (which ones, exactly?)
# for mconf and nconf to lin properly.
--- crosstool-ng-1.15.0_old/kconfig/nconf.c 2012-04-30 16:54:20.000000000 -0400
+++ crosstool-ng-1.15.0/kconfig/nconf.c 2012-05-07 16:47:39.618358900 -0400
@@ -1518,7 +1518,7 @@
}
notimeout(stdscr, FALSE);
- ESCDELAY = 1;
+ set_escdelay(1);
/* set btns menu */
curses_menu = new_menu(curses_menu_items);
--
-------------------- egibc 2.12 cygwin patch -------------------------
--- eglibc-2_9/timezone/Makefile.org 2011-02-08 10:46:29.000000000 +0100
+++ eglibc-2_9/timezone/Makefile 2011-02-08 10:45:34.000000000 +0100
@@ -176,6 +176,22 @@
$(zic-cmd) -p $(posixrules)
endif
+OS?= $(shell uname)
+ifeq ($(OS),Darwin)
+CROSSZICLDFLAGS=-L/opt/local/lib -lintl
+endif
+ifneq (,$(findstring Windows_NT,$(OS)))
+# cygwin!
+CROSSZICLDFLAGS=-L/usr/lib -lintl
+endif
+ifneq (,$(findstring CYGWIN_NT,$(OS)))
+# cygwin!
+CROSSZICLDFLAGS=-L/usr/lib -lintl
+endif
+ifeq ($(OS),FreeBSD)
+CROSSZICLDFLAGS=-L/usr/local/lib -lintl
+endif
+
zic-objs = zic.o ialloc.o scheck.o
$(objpfx)zic: $(addprefix $(objpfx), $(zic-objs))
@@ -185,7 +193,7 @@
-DCROSS_ZIC $(compile-mkdep-flags)
$(objpfx)cross-zic: $(addprefix $(objpfx)cross-,$(zic-objs))
- gcc $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@
+ gcc $(addprefix $(objpfx)cross-,$(zic-objs)) $(CROSSZICLDFLAGS) -o $@
tz-cflags = -DTZDIR='"$(zonedir)"' \
-DTZDEFAULT='"$(localtime-file)"' \
--- eglibc-2_12/sunrpc/rpc/types.h.org 2011-02-07 20:48:29.000000000 +0100
+++ eglibc-2_12/sunrpc/rpc/types.h 2011-02-08 01:25:34.000000000 +0100
@@ -69,6 +69,7 @@
#endif
#ifndef __u_char_defined
+#if !defined(__APPLE__) && !defined(__BSD__) && !defined(_BSDTYPES_DEFINED)
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
@@ -76,11 +77,14 @@
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
+#endif
# define __u_char_defined
#endif
#ifndef __daddr_t_defined
+#if !defined(__APPLE__) && !defined(__BSD__) && !defined(_BSDTYPES_DEFINED)
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
+#endif
# define __daddr_t_defined
#endif
--- eglibc-2_9/sunrpc/Makefile.org 2011-02-08 01:02:15.000000000 +0100
+++ eglibc-2_9/sunrpc/Makefile 2011-02-08 01:21:03.000000000 +0100
@@ -138,6 +138,22 @@
include ../Rules
+OS?= $(shell uname)
+ifeq ($(OS),Darwin)
+CROSSRPCLDFLAGS=-L/opt/local/lib -lintl
+endif
+ifneq (,$(findstring Windows_NT,$(OS)))
+# cygwin!
+CROSSRPCLDFLAGS=-L/usr/lib -lintl
+endif
+ifneq (,$(findstring CYGWIN_NT,$(OS)))
+# cygwin!
+CROSSRPCLDFLAGS=-L/usr/lib -lintl
+endif
+ifeq ($(OS),FreeBSD)
+CROSSRPCLDFLAGS=-L/usr/local/lib -lintl
+endif
+
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
$(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
@@ -148,7 +156,7 @@
$(OUTPUT_OPTION) $(compile-mkdep-flags)
$(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs))
- gcc $^ -o $@
+ gcc $^ $(CROSSRPCLDFLAGS) -o $@
# This makes sure -DNOT_IN_libc is passed for all these modules.
cpp-srcs-left := $(rpcgen-objs:.o=.c)
--