Begginer's C / C++ Development Guide


wardred

Member
Joined
Dec 18, 2008
Messages
392
Location
Minneapolis, MN
Website
thorslongboat.com
Success on the F200!
I used Neuvo's chroot so I don't kill my native build environment.
I used DJWillis's build tools for the GP2X - not to be confused with the older GP32.
I fixed *a bunch* of problems with my handmade make file - things that didn't show up in my native environment.
Also, a lot of thanks go out to Madsy^ on freenode's #gcc forum. She straightened a lot of my mistakes out in my hand made Make file.
Still need to get joystick code going - was all PC before, so I was just using the keyboard.

Well, it's hacked up to all Hell and back, but ToeHead for GP2X F200 finally works, such as it is. (Character just runs left and right.)

I'll write up detailed instructions in a bit. There was a bit on the GCC front that I had to struggle through that *just worked* natively - even though I had some of it wrong.

Limited progress so far.
From below, I believe I have arm-elf-g++ installed properly, but I *THINK* I need to re-build libraries for arm. Downloading the Gentoo env and installing Code Sourcery. With Code Sourcery it looks like I'm in the download SDL source, then run ./configure host=ia64-*-linux target=arm-*-elf and libtool madness.

Since I posted this, a bunch of posts have come up that should help the newb cross-compiler:
From Sphinxter: Open Embedded: Open Embedded
From Viridior: Neuvoo - embedded Gentoo: Neuvoo - embedded Gentoo
The linked page contains instructions for setting up a chroot environment to build your arm toolchain in.
If like me it's been a while since you've checked out project, (months in my case,) it's worth checking out again.

Cross Compiler Instructions.
I think the trickiest thing isn't installing the cross compiler, but getting the PATHS and libraries built.

GP32 Dev - predecesor to F200
GP32 FAQ

Many thanks to DJWillis who helped me on IRC. GP2X TOOLCHAIN
Somewhere there are probably his notes floating around for setting up a GCC compiler for the GP2X. (Not just using the toolchain.)
Please note: the GP2X toolchain is *NOT* what you'll use for the Pandora. The concepts used to setup the toolchain may be similar to setting up the Pandora's cross-dev environment, but it'll be a whole new toolchain to compile for the Pandora.

This page: hardwarebug.org has some info and suggestions on compilers based on speed and bugs.

There are both versions for devices running Linux, and for bare metal.
For the F100, F200, Dingoo, Wiz, and Pandora, make sure you grab the one for Linux.
Code Sourcery 2009q1: Code Sourcery
Code Sourcery 2007q3: Code Sourcery

Pandora Unofficial SDK Installer: Pandora Unofficial SDK Installer

The "new way to program for the Pandora" cross dev thread: New Way To Program

Thread from 2008 that looks like it covers some of the same issues I'm having now, but for Windows:
Setting up your toolchain and SDL libs
I feel now how Gruso sounds like he felt then, minus the having the SDL test up and working.

GBA Register Reference
Arm 7 Reference


All,
I'm a beginner when it comes to c++, and an utter newb when it comes to cross compiling. I'm struggling a bit to get my development environment up and running, and hoping not to bork my Linux64-bit G++ environment distributed by Ubuntu. (Or gentoo, OpenSuse, or whatever I happen to have installed at the moment.)

I'll be writing up what I find on my website - http://ffa-games.com/tutorials , and copying the info here. Initially whatever I do will probably be for gp32 and Beagle Board until I get my Pandora. (My efforts to get this working spurred on by the Pandora Angst Contest.)

I have 2 goals for this project. The first is to give a step-by-step guide for the utter newb like me that finds getting the dev environment setup almost as arcane as the c / c++ language itself. Initially it may not be the "best" solution, but it should work.

Eventually I'd like to get this thing down to a "best practices". I don't know if that's using codesourcery or a similar pre-configured environment, simply downloading the GNU tools and setting them up for ARM, or getting your current dev tools to work, somehow, as a cross compiler without breaking them for use as the primary X86/X86-64 compiler for your given environment. I'd *GUESS* that it'll come down to either codesourcery and/or specific versions of the GNU compiler and the various libraries so that if I'm using Qt, I'm using the version of Qt provided by Pandora. (Or GP32, or Dingoo, what have you.)

The END GOAL is to go into everything needed for the various platforms. For the Pandora that would include where to get the development tools for the DSP, audio out, 3d GLES 2.0 out, any GL wrappers such as the stuff Pickle wrapped the Q3 code in, getting GLES 1.x to work on the Pandora, etc. and have it all in one place. And if there are different ways of doing things, highlighting the advantages / disadvantages of them.

Oh, yes, the libraries. Qt 4.x, SDL 1.2, and maybe SDL 1.3. OpenGL probably 3, OpenGLES 2.0 at the least, possibly OpenGL 1.x for compatibility, OpenGL wrapper. (Others would support other libraries, these are the ones I'm going to focus on.) Probably ALSA for sound, maybe OpenAL...

There seems to be some stuff out there already, but it seems pretty broken up. (The Developer's FAQ, for instance, seems pretty incomplete as of this writing.)

If this is redundant and I'm missing a step by step how-to already, then by all means, let me know.
 
Last edited by a moderator:
We have a cross compiling env guide here: http://neuvoo.org/wiki/index.php?title=Hand-craft_an_Image/Create_Cross-Compiler_Environment

Intentions with that guide is to set up a cross compiling environment for building a entire OS, but since its Gentoo and built for compiling anyway, it is inherently easy to cross compile your programs also.

Let me know if you need any help.

FYI: another good thing about this is that you can use Gentoo for your cross compiling env by unpacking the stage3 in your default OS (Ubuntu, etc) and just chroot into when you want to cross compile. This is really nice if you want to ensure that you wont mess up your host system by accidently installing ARM code in your x86 system.
 
Viridior, that page is in a lot better shape than the last time I visited. It's been a long while since I've been to Neuvoo's site. chroot is certainly one way to without messing with your local environment. I'll spend some time perusing there, thank you.

Edit: For the time being I've simply setup a new GCC install, based off the instructions here: http://www.6809.org.uk/gp32/build-cross-compiler.shtml

The main difficulty I'm running into is my regular cross-compiler will find SDL, but arm-elf-g++ doesn't. Ah well, I have homework I need to do. It'll be a few days before I can dig into it again.

Edit 2: And I spent way too much time yesterday fighting with an SD card that didn't want to format. I don't know if that was because Linux was being a pain and not recognizing in a timely fashion that I'd removed the partitions, then repartitioned as fat32, or if it was auto-mounting as I was doing disk operations, or what. I'll try formatting in Windows, if that doesn't work, then the disk is probably dead. (I eventually gave up and went on to another SD drive.)

Edit 3: Editapalooza - Other than formatting a program for ARM, and using SDL to get something to display on the screen, are there any tricks to getting something to run on the GP2X?
 
Being very very new to C++ (and not a very experienced programmer in general) this knowledge will do me a world of good as I plan to develop for everything I can get my hands on. The Pandora is really what has inspired me to work hard in learning a very mobile and powerful language instead of just learning whatever would allow me to develop for Windows. Thank you for taking the time to provide these resources to people like myself.
 
wardred said:
Viridior, that page is in a lot better shape than the last time I visited. It's been a long while since I've been to Neuvoo's site. chroot is certainly one way to without messing with your local environment. I'll spend some time perusing there, thank you.

Edit: For the time being I've simply setup a new GCC install, based off the instructions here: http://www.6809.org....-compiler.shtml

The main difficulty I'm running into is my regular cross-compiler will find SDL, but arm-elf-g++ doesn't. Ah well, I have homework I need to do. It'll be a few days before I can dig into it again.

Edit 2: And I spent way too much time yesterday fighting with an SD card that didn't want to format. I don't know if that was because Linux was being a pain and not recognizing in a timely fashion that I'd removed the partitions, then repartitioned as fat32, or if it was auto-mounting as I was doing disk operations, or what. I'll try formatting in Windows, if that doesn't work, then the disk is probably dead. (I eventually gave up and went on to another SD drive.)

Edit 3: Editapalooza - Other than formatting a program for ARM, and using SDL to get something to display on the screen, are there any tricks to getting something to run on the GP2X?

Link static and use SDL_SWSURFACE.
 
Last edited by a moderator:
okay, this probably isn't the recommended way to do things, but it's bugging me. The below snipped from: http://www.6809.org.uk/gp32/build-cross-compiler.shtml
I get it to build just fine, but it can never find "SDL/SDL.h" where my "normal" g++ has no issues. I'm going to check out Neuvo's build environment, the recently posted Pandora SDK, and a few other links over the weekend, but does anybody know what I have to do to get arm-elf-g++ to see SDL/SDL.h?

Thanks


Preparing to build
Unpack archives

$ gzip -dc binutils-2.16.tar.gz | tar xf -
$ gzip -dc gcc-3.4.3.tar.gz | tar xf -
$ gzip newlib-1.13.0.tar.gz | tar xf -

Prepare newlib to be built along with gcc

$ cd gcc-3.4.3
$ ln -s ../newlib-1.13.0/newlib .
$ cd ..

Build everything

If you want to store all the build stuff in its own tree, add a --prefix=/path/to/stuff option to each of the configure lines below.
Build binutils

$ mkdir binutils-2.16-arm-elf
$ cd binutils-2.16-arm-elf
$ ../binutils-2.16/configure --srcdir=../binutils-2.16 --target=arm-elf
$ make
$ su -c "make install"
$ cd ..

Build gcc

$ mkdir gcc-3.4.3-arm-elf
$ cd gcc-3.4.3-arm-elf
$ ../gcc-3.4.3/configure --srcdir=../gcc-3.4.3 --target=arm-elf \
--with-cpu=arm9 --with-newlib --disable-threads --disable-multilib \
--disable-nls --enable-languages=c
$ make
$ su -c "make install"
 
Back
Top