CrossCompile IDE Setup


pmprog

DNF (Did Not Finish)
Joined
Apr 25, 2011
Messages
4,150
Okay, I'm kinda newish to Linux. I've played previously, but as my work environment is Windows and most of the tools I use are generally Windows based, I'm in unfamiliar surroundings.


I've set up a VM with Ubuntu v10.10 x64


I've followed ivanovic's toolchain setup here - http://www.gp32x.de/board/index.php?/topic/58443-crosscompiler-toolchain-based-on-openpandora-org-ipks/page__p__936553&#entry936553


Everything seemed to install okay, and I've also downloaded KDevelop (which for some reason crashes on closing, oh well)


Question I have is, how do I create a Pandora project? If I create a C++ project, it compiles and runs on that system. Does anybody have a KDevelop Template?


I'm pretty open to using any other editors if anyone can tell me how to set up one of them. The only feature I'd really prefer to have is Autocomplete, anything is is superfluous ;)


Cheers
 
Last edited by a moderator:
Hi,


i'm a newbe too, but i want to share my experience, hoping to help you.


I have installed sebt3 Yactfeau toolchain using the virtualbox image.


With this you can configure and compile using the shell...but read the thread for more info on how to do this.


I'm not a programmer or an expert, but i like to try, in my spare time, to port something for my lovely handhelds (Pandora and GP2X).


Now since i feel better with and IDE, and i prefer Codeblocks for my porting effort, i have installed this via Ubuntu Software Center inside of the virtualbox image.


I have configured it and now i can choose to compile with Codeblocks or in a terminal using the standard tools.


If you need help on setup the Codeblocks let me know.


Farox
 
Last edited by a moderator:
Be a good coder and get to know your compiler ;)


Start off with manually compiling your stuff, get some basic experience and knowledge about the whole GCC toolchain hidden behind the IDE. It ain't as complex as it may seem at first, you'll learn it very quickly. Then it is absolutely self-explanatory what you need to do to set up your IDE for cross-compiling (however, KDevelop can get kinda confusing regarding such cross-compiler set-ups as it's using an autoconf environment instead of an own build system like Code::Blocks, so you'll have to read into cross-compiling with autoconf/configure instead - or did they switched to another system by now?).


Eventually you'll even tend to leave full IDEs (e.g. because you notice that they're rather hindering you instead of helping you, like I did) and do it the manual way as kind of all Linux hackers do.


BTW: Ubuntu 11.04 finally got an ARM cross-compiler in its repos, I guess it's configured to aim at the ARM platform targeted by Ubuntu's ARM version by default - which fits just perfect to the Pandora's SoC. The rest should simply be a matter of copying a few default libs over to the cross-compiling environment.
 
Does anybody have a KDevelop Template?
No need for that, Kdevelop produce autoconf scripts and/or Cmake conf.


Just ask it to generate the appropriate file and configure manually. once done the build function of kdevelop should work (as it call make ;P)


ho, and I'm providing a virtualbox image with ubuntu and a working toolchain in the thread Farox linked too ;)
 
Last edited by a moderator:
Be a good coder and get to know your compiler ;)
That's good and all, if you actually know enough to play. When I used to code Dos/Win Assembler, everything compiled via a batch calling the compiler and linker etc., it was easy to do.


When I first started looking at C, everybody typed "make", and I couldn't find anybody that would tell me where the makefile came from. So yeah, I guess I relied on Visual Studio to handle the building of my C/C++ projects.

Does anybody have a KDevelop Template?
No need for that, Kdevelop produce autoconf scripts and/or Cmake conf.


Just ask it to generate the appropriate file and configure manually. once done the build function of kdevelop should work (as it call make ;P)
I tried creating an ARMGCC project, it asked me for an evaluation board(?), pointed the compiler settings to my pandora-dev/ARM2010.09 folder and specified the compilers as the pandora-* files. However, when I tried to compile it told me it couldn't find pandora-gcc I think, and AFAIK I've set it all up correctly. I even put the pandora-dev/ARM2010.09/bin folder in the "additional paths" section

ho, and I'm providing a virtualbox image with ubuntu and a working toolchain in the thread Farox linked too ;)
Yep, downloaded that. Will try tonight/over the weekend to get something to compile.


I'm about to go to the post office to pick up my Pandora and then it's off to work.


Cheers guys, and I'm sure I'll be back with a few more questions
 
Makefiles:


Some good tutorials can be found by googling - I'm not telling you to RTFM/STFW, but maybe you looked at makefiles a long time ago, because I know when I made my first makefile, there wasn't many good tutorials indexed by google at the time.


An example, simple (don't be scared off! Makefiles are actually quite simple!) makefile I made myself looks like this:



Code:
# Build everything; just calls make...


all: game.c editor.c tiles.h # will do it if any these files have changed since last build

        echo Making editor and game with default platform

        make game

        make editor


# Build the game


game: game.c vars.h defines.h menu.h funcs.h funcdefs.h tiles.h structs.h stats.h # if none of these have changed, exit

	echo Making game for default platform

	g++ game.c -o game -lSDL -lSDL_ttf -lSDL_image -Wall -Wno-unused-result -O3 # Compile the program with the GNU C++ Compiler, producing the system-native (for me it's x86_64) binary 'game' with the SDL, SDL_ttf and SDL_image libraries. All warnings except no-unused-result are turned on. A level 3 optimisation is enabled.


# Build the editor


editor: editor.c menu.h tiles.h # again, these must have changed or make will exit

	echo Making editor for default platform

	g++ editor.c -o editor -lSDL -lSDL_ttf -lSDL_image -Wall -Wno-unused-result -O3 # Compile the program, producing the binary 'editor', much like the above


Hope this helps! There are also variables, it all works much like a (ba)sh script. Personally I do not use variables- but I probably should.


If you want, you COULD write a (ba)sh script instead!


Code::blocks allows you to specify your own makefile, don't know about other editors. IDEs honestly complicate stuff too much, if it wasn't for the AWESOME autocompletion(Code::blocks will follow #includes, Geany will not), I'd go back to using Nano and/or Geany and makefiles (which I often use anyway).
 
Be a good coder and get to know your compiler ;)
That's good and all, if you actually know enough to play. When I used to code Dos/Win Assembler, everything compiled via a batch calling the compiler and linker etc., it was easy to do.


When I first started looking at C, everybody typed "make", and I couldn't find anybody that would tell me where the makefile came from. So yeah, I guess I relied on Visual Studio to handle the building of my C/C++ projects.

Here's a primer:


Makefiles are fairly simple creatures that can either be typed manually or generated. Generating makefiles with autotools (configure), cmake or qmake is common in larger projects, because make is a fairly low-level tool that does little automating itself. Basically it has wildcard-enabled rules with dependency-based processing. The makefile generators add to this by adding conceptes of applications, libraries, source files and so on. This makes (pun not intended) it easier to manage large projects without having an insanely complex makefile and start projects faster by providing smart defaults for the build process.


The actual command needed to compile with for example g++ in its most simple form is:



Code:
g++ main.cpp



If you have several source files you do:



Code:
g++ main.cpp other.cpp yetanother.cpp



To link with a library (SDL in this example):



Code:
g++ main.cpp other.cpp yetanother.cpp -lSDL


...and so on. It's not really that difficult. Makefiles make the compilation quicker by only compiling changed stuff. This is achieved by first compiling each cpp file into an object file (eg. main.o), which are then linked to make up the actual program binary. By time stamps in the source- and object files it's possible to deduce what sources need to be recompiled, which is what make leverages.
 
Cheers guys. How do either of those examples work? because you aren't specifying you want to build ARM? Or were those examples building on the Pandora?


Anyhoo, I have found in the make file of qnetwalk on sebt3's VM the path and executable names of the tools, and have just compiled a simple "Hello" test and run it on my Pandora successfully.


So I guess, the only bit I need to sort out now is creating PND files.


Thanks again
 
Last edited by a moderator:
Those are general GCC commands, it will use the native compiler if the environment wasn't changed to use another one instead, e.g. by using chroot or aliases. To compile for another architecture you need to replace gcc/g++ (gcc is for C, g++ for C++) with their equivalents of the target platform. GCC Cross-compilers provided by the repositories of the system usually use a platform prefix. Taking Ubuntu's ARM and Win32 cross-compilers as an example, arm-linux-gnueabi-g++ would be the ARM g++ (with all its files being in /usr/arm-linux-gnueabi) and i586-mingw32msvc-g++ (with all its files being in /usr/i586-mingw32msvc) would be the Win32 g++ of MinGW. GCC Cross-compilers in SDK-like standalone packages usually don't have any prefix, you simply need to provide the full path so it will take it instead of the system's native ones.


An exception is compiling for x86 from an AMD64 system as the system can use x86 files itself (of which the libraries are stored in /usr/lib32 etc), then you just need the -m32 parameter.
 
If you need help on setup the Codeblocks let me know.

I have the CDevTools working with Geany. But I would like to use Codeblocks occassionally. I especially would like my CB work in Windows to be compiled for the Pandora as well. I can do this in GLbasic (it will create an exe and PND).


How do I setup Windows CodeBlocks to commpile for the Pandora?
 
If you need help on setup the Codeblocks let me know.

How do I setup Windows CodeBlocks to commpile for the Pandora?

Its very easy go to settings in the menu bar.


Hit the copy button with GNU GCC Compilier selected. Rename it to something pandoraish.


It should select the new config, set your search paths to point the include and lib dir in the cross compiler locations. You may also want to include 'include/SDL' or whatever special headers. you can also add libs to link in the linker settings, but you can do this per project.


Go to toolchain executables tab and set the path above the bin in your cross compiler. Dont hit autodetect.


Change the names for the executbales for gcc, g++, all other can be anything.
 
Well Cross-Compiling is a first but I learned a couple things.

ia32-2011.09-24-i686-pc-linux-gnu.exe is for coss-compiling apps to run on Linux systems on a "Intel" chip.

arm-2011.09-70-arm-linux-gnu_eabi.exe is for coss-compiling apps to run on Linux systems on an ARM chip. Like the Pandora or RasberryPi


New stuff for me. And it took a little figuring but I am taking notes and screenshots of the settings.

Is there a way to change CodeBlocks so that the compile program is NOT tagged ".exe" nor test-ran after compiling on windows (which sometimes has nasty side-effects).

Thanks for the instructions. And the reference to the CodeSourcery Toolchain gave me what I needed.

I compiled a simple HelloWorld that ran in VirtualBox Ubuntu. Success
And Compiled it to turn on the Pandora - and Again Success

Thanks Guys!
 
Last edited by a moderator:
Is there a way to change CodeBlocks so that the compile program is NOT tagged".exe" and NOT test-rand after compiling on windows (which sometimes has nasty side-effects).

Look in your project properties -> build targets and look for the auto-generate* check boxes

OK My code is ONE file so I am not using a project. Just loaded the one CPP and compiled for Windows no problem but There are no project or Build options activated when not using a full Project? If I must I can simply delete the EXE off my Linux versions.


But this brought a second problem up. Also, When trying to compile a Linux version which included an <io.h>. My windows version compiled fine but when I switched to Linux I got the following...


C:\Documents\Programming\CodeBlocks\CPP2HTM\cpp2html.cpp|12|fatal error: io.h: No such file or directory|


||=== Build finished: 1 errors, 0 warnings ===|


I thought it would be a simple matter to port my code from MSVC and TurboC.


Is this an easy thing or have I reach the point of stopping until I finish all the manuals? I setup CodeSourcery and Got HelloWorld cross compiled for Pandora and Ubuntu so the basic setup is done but I am wondering if I must build a project for anything that has includes? No quick single-file easy compiles?
 
I don't have io.h on my linux system, are you sure it's part of the standard?

Well it was in my code from 2000 and it was in my includes in both MinGW and MSys which I installed last month. But you are right it seems to be a legacy file. It works with my Windows compiles but not any Linux compiles in CodeBlocks.
 
I don't have io.h on my linux system, are you sure it's part of the standard?

Well it was in my code from 2000 and it was in my includes in both MinGW and MSys which I installed last month. But you are right it seems to be a legacy file. It works with my Windows compiles but not any Linux compiles in CodeBlocks.

I dont recall that header, so it may be windows specifc. But maybe stdio.h does what you need.
 
Back
Top