Cross-Compiler for Windows


62 posts   Page 1 of 3   1, 2, 3
by Toad King » Tue Mar 13, 2012 5:04 pm
Does anybody know of any method for cross-compiling Ras-Pi programs/libraries from Windows? I know there are some Linux/Unix methods, but I can't find any from Windows. Am I going to be forced to use a virtual machine for it?
User avatar
Posts: 156
Joined: Sun Dec 18, 2011 8:03 pm
by naicheben » Tue Mar 13, 2012 6:22 pm
You could install Linux beside your Windows installation (Dual-boot).
Posts: 338
Joined: Sat Jan 28, 2012 12:28 pm
by naicheben » Tue Mar 13, 2012 6:26 pm
Ah, and another way could be to boot from USB-HD/USB-Stick but it's much slower. I compiled some applications (MMS and VDR) on a Pentium M @700MHz with 128MB RAM booting Debian Lenny from USB-HD. If you have much time, this could be an option.
Posts: 338
Joined: Sat Jan 28, 2012 12:28 pm
by Toad King » Tue Mar 13, 2012 6:32 pm
Both of those options would be more cumbersome that a straight VM with Linux on it, since constantly rebooting between Linux and Windows would kill way too much time. I was hoping for a native Windows solution (or possibly something through Cygwin).
User avatar
Posts: 156
Joined: Sun Dec 18, 2011 8:03 pm
by rurwin » Tue Mar 13, 2012 6:38 pm
There is almost certainly no way through native Windows, there may be a way through Cygwin, but I have no idea how to do it.
User avatar
Moderator
Moderator
Posts: 2890
Joined: Mon Jan 09, 2012 3:16 pm
by hippy » Tue Mar 13, 2012 7:34 pm
The free Sourcery Lite toolchain easily installs on a Windows PC and runs from the command prompt without faffing about with Cygwin or MingW. Just invoke the compiler .exe with the name of the input .c file and that's it.

https://sourcery.mentor.com/sgpp/lite/arm/portal/subscription?@template=lite

Select the GNU/Linux package then IA32 Windows Installer from the recommended packages.

I haven't tested with R-Pi but their X86 cross-compiler works for creating console apps which run under Ubuntu.
Posts: 756
Joined: Fri Sep 09, 2011 10:34 pm
by SKGenius » Tue Mar 13, 2012 8:49 pm
My current method is to use Windows and Visual Studio to manage my projects, combined with MakeItSo to generate makefiles for the solution. I then have a VM with linux on it which has access to my projects folder so all I have to do is type "make, and it should be much easier to build for the R-Pi in a Linux VM than all the way from Windows.

It might not be convenient for everybody, but as I"m making cross platform stuff I can test and debug on Windows and I only need to pop over to Linux to make a build (and check the Linux specific stuff is working)

I was initially looking for a more direct route though, so if you get anything set up let me know.
Posts: 1
Joined: Sun Mar 04, 2012 12:24 pm
by pgix » Wed Mar 14, 2012 11:13 am
Hi,

I do quite a lot of hobby os stuff and use Cygwin for all my cross compilation. There's a tutorial here: http://wiki.osdev.org/GCC_Cross-Compiler on how to build a GCC x86 ELF cross compiler for Windows - if you already know how cross-compilers work on Linux, you should be able to adapt it to target the R-Pi.

Cheers,

Adam
Posts: 23
Joined: Wed Jan 25, 2012 3:53 pm
by ArborealSeer » Fri Apr 27, 2012 1:01 pm
SKGenius said: 


It might not be convenient for everybody, but as I"m making cross platform stuff I can test and debug on Windows and I only need to pop over to Linux to make a build (and check the Linux specific stuff is working)



Exactly what I want too, can do all the profiling, mem usage and lint type stuff on the windows build and switch builds, for the most part there would just need to be a bit of platform specific code to get it up n running.

If it could be combined with a batch file to use gcc directly on windows it'd help.

A howto guide for this would be awesome.
Pi Status > Farnell, Arrived 24/5- RS, Arrived 1/6
User avatar
Posts: 292
Joined: Tue Jan 24, 2012 9:48 am
by r3d4 » Sat Apr 28, 2012 8:29 am
Toad King said:


Both of those options would be more cumbersome that a straight VM with Linux on it, since constantly rebooting between Linux and Windows would kill way too much time. I was hoping for a native Windows solution (or possibly something through Cygwin).


maby

you could try
http://www.colinux.org/

"Cooperative Linux is the first working free and open source method for optimally running Linux on Microsoft Windows natively."

?
Posts: 26
Joined: Sat Jul 30, 2011 8:21 am
by IanLinsdell » Thu Jul 05, 2012 5:16 pm
I have built Windows cross compilers for ARM before using 'crosstool' with cygwin which worked great, even modified and recompiled kernel which worked without issues on a Cirrus Logic ARM.
I used Eclipse (Windows, C++ plugin) and compiled directly to a NFS mount on the actual hardware. Then tested on the hardware itself.

You should be able to use 'crosstools' successor 'crosstoold-ng' and cygwin to build a Windows cross compiler for the RasPi. I quickly tried (only spent 30 mins) and it appeared that it should be do able, got some error about crosstool-ng not being able to find curses header file. Maybe will get more time to work it out later.

Currently I do not have a RasPi but am using QEmu to emulate and compile RasPi ARM binaries on Windows 7.
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by arturo777 » Fri Jul 06, 2012 12:44 pm
Another tool chain is YAGARTO: "Yet another GNU ARM toolchain".

http://www.yagarto.de/
Posts: 27
Joined: Sat Mar 24, 2012 10:02 am
by IanLinsdell » Fri Jul 06, 2012 4:58 pm
YAGARTO is more suitable for embedded ARM development rather than Linux arm, hence the toolchain is 'arm-x-none' instead of 'arm-x-linux'.
You will have to provide main/stack initialization code/library.

I think best bet is to use cygwin and crosstools-ng to generate a 'arm-unknown-linux-gnu' crosstool.
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by IanLinsdell » Tue Jul 10, 2012 4:44 pm
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)
--
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by IanLinsdell » Wed Jul 11, 2012 8:24 pm
Pre Compiled Windows -> Raspberry Pi GCC Compiler can be found here:
https://github.com/IanLinsdell/Raspberrypi
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by Dexterp37 » Mon Jul 30, 2012 7:56 pm
IanLinsdell wrote:Pre Compiled Windows -> Raspberry Pi GCC Compiler can be found here:
https://github.com/IanLinsdell/Raspberrypi


Hi Ian, thanks for your help!

How to make it work inside Eclipse? I read in another thread that you are using Eclipse CDT + GCC on Windows.

Does it need cygwin?

Thanks!
Posts: 21
Joined: Mon Jul 30, 2012 7:51 pm
Location: Italy
by IanLinsdell » Mon Jul 30, 2012 9:42 pm
Hi Dexterp37,

You will need either cygwin or mingw. (All you really need is enough to run the 'make' tool)

I am using cygwin.

Ian.
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by Dexterp37 » Tue Jul 31, 2012 9:47 am
IanLinsdell wrote:Hi Dexterp37,

You will need either cygwin or mingw. (All you really need is enough to run the 'make' tool)

I am using cygwin.

Ian.


I'm sorry to bother you, but that's my first cross compilation on Windows! Once I've installed Cygwin and downloaded your pre-compiled gcc, where should I unpack it?
Posts: 21
Joined: Mon Jul 30, 2012 7:51 pm
Location: Italy
by CopperPhil » Tue Jul 31, 2012 12:22 pm
Hi Dexterp37,

I'm facing the same problem... I'm working for two days on building a simple hello world app on my PC in order to make it running on the raspberry :-)

I just succeeded to build the program. I don't know yet if it works on the rpi, but here is how I proceed to get it building with no error.

- install Eclipse with CDT
- install Cygwin
- extract cross-arm-gcc-softfpV1 somewhere (let's say in "...\toolchain")
- create a simple hello world program
- go to project properties, then:
* c++ build/Environment: add a variable CYGWIN = nodosfilewarning
* c++ build/Environment: add to PATH "...\toolchain\cross-arm-gcc-softfpV1\cross\x-tools\arm-unknown-linux-gnueabi\bin"
* c++ build/Environment: add to PATH "C:\cygwin\bin"
* c++ build/Tool Chain Editor: current toolchain = Cygwin GCC
* c++ build/Settings/Tools Settings/Cygwin C++ compiler: Command = arm-unknown-linux-gnueabi-g++
* c++ build/Settings/Tools Settings/Cygwin C++ compiler/Includes: Include path = "...\toolchain\cross-arm-gcc-softfpV1\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\include"
* c++ build/Settings/Tools Settings/Cygwin C compiler: Command = arm-unknown-linux-gnueabi-g++
* c++ build/Settings/Tools Settings/Cygwin C compiler/Includes: Include path = "...\toolchain\cross-arm-gcc-softfpV1\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\include"

* c++ build/Settings/Tools Settings/Cygwin C++ linker: Command = arm-unknown-linux-gnueabi-g++
* c++ build/Settings/Tools Settings/Cygwin C++ linker/Librarties: Library search path = "...\toolchain\cross-arm-gcc-softfpV1\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\usr\lib"

I'll check now if it's working on the rpi... :?:

Then... I still have to understand to to perform remote debugging... :?
-- CopperPhil --
Posts: 5
Joined: Mon Jul 30, 2012 4:37 pm
Location: Brussels
by Dexterp37 » Tue Jul 31, 2012 12:49 pm
Hi CopperPhil,

thank you very much! You saved my day (and probably the night too! :D ). I'll test it once I get back home and let you know!

By the way, I found this guide for doing remote debugging on Raspberry Pi. I did not have time to test it, but I think it will work ;)

Thanks again!
Posts: 21
Joined: Mon Jul 30, 2012 7:51 pm
Location: Italy
by IanLinsdell » Tue Jul 31, 2012 1:07 pm
I have seen most people extracting cross tools into the /opt directory so that is what I used.

1. Download Cygwin (You only really need the make tool and the shell to run it)

2. Extract the cross compiler (If usnig QEMU to test your app use the soft float version) into the /opt
directory. e.g. C:\cygwin\opt\

Your expanded cross compiler should be expanded into the following directory:
e.g. C:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi

3. Download and install Eclipse and CDT plugin.

Example configuring Eclipse and CDT with the cross compiler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A. Create a new C++ project in a subdirectory HelloRasPi.
Set your Eclipse > project > properties > Build command to: ..\cygwin.bat ./eclipsemake.sh HelloRasPi

Set Eclipse > project > properties > C/C++ Genral > Code Analysis > Launching: Check 'Run with build'

B. In one directory above my Eclipse project directories I have the following two files:
----------------------------------------------------- cygwin.bat -----------------------------------------
@echo off
C:
chdir c:\cygwin
SET HOME=/cygdrive/c/Data/RaspberryPi/crosstools/Examples
bin\bash --login %1 %2 %3 %4 %5 %6 %7 %8
exit /b %ERRORLEVEL%
----------------------------------------------------- eclipsemake.sh -----------------------------------------
#!/bin/sh
# cd into the project subdirectory
cd "$1"
# Location of cross compiler tools and directories
CROSS_COMPILE="/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-"
export CROSS_COMPILE
make $2 $3 $4 $5 $6 $7 $8

C. Below is an Example Makefile and hello project (Both should be located in your project directory: HelloRasPi)
-------------------------------------------------------------- Makefile ------------------------------------------
# Includes and Libraries
#INC_RS_COMMON=-I../../../../../RS_Common/src
#LIB_RS_COMMON=-L../../../../../RS_Common/bin

# OEM Includes and Libraries
#INC_BOOST=-I../../../../../RS_Common/oem/Boost\ 1.35.0
#LIB_BOOST=-L../../../../../RS_Common/oem/Boost\ 1.35.0/lib

# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump

export AS LD CC CXX CPP AR NM STRIP OBJCOPY OBJDUMP

# Compiler Flags: Debugging, Pos Indipendant Code-dynamic linking
#CXXFLAGS=-g -fPIC -DYOURVER=YOUR_$(YOUR_BUILD_VERSION)
BLDDIR=
PROG=./hello

# Source and Object files
SRC= hello.cpp
OBJS = $(subst cpp,o,$(SRC))

# Include Directories
#INCLUDES=$(INC_RS_COMMON) $(INC_BOOST)
#LDFLAGS=$(LIB_RS_COMMON) $(LIB_BOOST)

#LIBS=-ldl -lSimpleUtilities -lOSUtils -lCommonUtils -lEntCommonUtils -lwdls -lShared \
#-lboost_system -lboost_thread -lboost_filesystem -lboost_signals \
#../oem/libpcap-0.8.1/libpcap.a ../../../../../RS_Common/oem/srtp/libsrtp.a

# Look for libraries in current directory at runtime
#LDFLAGS+= -Wl,-rpath=.
LDFLAGS+= -mcpu=arm1176jzf-s -mfloat-abi=softfp
#LDFLAGS+= -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp


# Inference Rule to make .o targets
#%.o : %.cpp
# $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $(BLDDIR)$@ $<

# Subdirectories to Recurse Into
#SUBDIRS = Capture Source

#.PHONY all: subdirall depend $(PROG)

#subdirall :
# for dir in $(SUBDIRS); do cd $$dir; make all; RET=$$?;if [ $$RET != 0 ]; then exit $$RET; fi;cd ..; done;

#(PROG) : $(OBJS)
# $(CXX) $(LDFLAGS) -o $@ *.o Capture/*.o Capture/*/*.o AnalyzeThread/*.o Source/*.o SIPKeepAlive/*.o $(LIBS)
# $(STRIP) $(PROG)

all :
$(CXX) $(LDFLAGS) -o $(PROG) $(SRC)

clean :
rm *.d $(PROG)
# for dir in $(SUBDIRS); do cd $$dir; $(MAKE) clean; cd ..; done
# - rm *.o *.d $(PROG)

# Generate dependencies for each .cpp file
DEPS = $(subst cpp,d,$(SRC))
depend: $(DEPS)

# Include make target and dependencies from .d file if target is not clean
ifneq ($(MAKECMDGOALS),clean)
-include $(SRC:.cpp=.d)
endif

# Inference Rule to make .d targets
%.d: %.cpp
$(CXX) -M $(INCLUDES) $(CXXFLAGS) $< > $@

-------------------------------------------------------------- hello.cpp ------------------------------------------
#include <iostream>

int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by IanLinsdell » Tue Jul 31, 2012 1:25 pm
P.S.

CopperPhil instructions should also work too, you may want to consider configuring this way, especially if you are uncomfortable with Makefiles.

The only reason I can think of to choose using a Makefile and the reason I use them is:

1. You want to be able to tweak a single Makefile stetting and compile for a different target.
e.g. I compile some GTK+ projects to run on RasPi, change a makefile variable and then
rebuild to run on Windows.

2. You want to compile an open source project from source code for the RasPi.
These almost always use Makefiles.
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm
by Dexterp37 » Tue Jul 31, 2012 1:32 pm
Thank you very much (both IanLinsdel and CopperPhil!).

I will follow your suggestions and let you know ;-) Regarding remote debugging, the owner of this blog succeeded in remotely debugging on Raspberry Pi (from a Debian machine).

ps: if that's a double post I'm sorry, I wrote a reply to CopperPhil a while back but somehow was not approved while your was :)
Posts: 21
Joined: Mon Jul 30, 2012 7:51 pm
Location: Italy
by CopperPhil » Tue Jul 31, 2012 3:03 pm
Well well well...... ok, I can build the my hello world program, transfer it through ssh in the rpi, then execute it on the board.

but now I need a little push to implement the remote debugging :oops: I tried the method found in the blog from the last Dexterp37 message, but without success... actually I don't know exactly how to configure the GDB. Moreover this method needs to manually copy the file to the target first... It seems that Eclipse is able to build, copy to the target, then launch the debugger at once... this seems to me a more interesting approach...

any help will be highly appreciated :)
-- CopperPhil --
Posts: 5
Joined: Mon Jul 30, 2012 4:37 pm
Location: Brussels
by IanLinsdell » Tue Jul 31, 2012 8:55 pm
I've not used Remote GDB for some time.

As for the build and copy to target, I typically use samba or NFS to export /mnt/win on the RaspPi so that I set my build target to the mounted filesystem. You can also do this using the QEMU emulator in the same way.

You should be able to run gdbserver on your RaspPi (already installed on Debian image) and then use a cross compiled version of gdb client from eclipse to connect to it.
This assumes that you can either find a download of a cross compiled version of GDB or cross compile it yourself.
Posts: 21
Joined: Fri Jun 29, 2012 9:34 pm