Jump to content


Photo

CrossCompile IDE Setup


  • Please log in to reply
16 replies to this topic

#1 OFFLINE   pmprog

pmprog

    www.pmprog.co.uk

  • Members
  • PipPipPip
  • 1558 posts
  • Local time: 04:40 PM
  • LocationCheshire, UK

Posted 05 May 2011 - 08:00 PM

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.com...53

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
pmprog.pngpandora.pngbutton-small.pngtournamenthub.pnggithub.png

#2 OFFLINE   Farox

Farox

    Advanced Member

  • Members
  • PipPipPip
  • 678 posts
  • Local time: 04:40 PM
  • LocationItaly

Donator

Posted 05 May 2011 - 08:42 PM

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
Read also my Blog http://farox.rbnet.it/

#3 ONLINE   Letalis Sonus

Letalis Sonus

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • Local time: 05:40 PM

Posted 05 May 2011 - 09:21 PM

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.

#4 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 1455 posts
  • Local time: 10:40 AM

Posted 05 May 2011 - 10:32 PM

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 ;)

- [ PNDS ] - [ Yactfeau ] -

Spoiler



#5 OFFLINE   pmprog

pmprog

    www.pmprog.co.uk

  • Members
  • PipPipPip
  • 1558 posts
  • Local time: 04:40 PM
  • LocationCheshire, UK

Posted 06 May 2011 - 05:38 AM

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
pmprog.pngpandora.pngbutton-small.pngtournamenthub.pnggithub.png

#6 OFFLINE   doublebeta

doublebeta

    Advanced Member

  • Members
  • PipPipPip
  • 158 posts
  • Local time: 01:40 AM
  • LocationNew South Wales, Australia

Posted 06 May 2011 - 06:14 AM

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:
# 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).
ARM/Pandora hardware/operating system gurus, please consider checking out: http://boards.openpa...tem-development

Linux user | NetBSD User | Emacs user | Nano user | Bash User | gnu lover
Be free. Don't let anybody push you, stay strong and they will never crush you.

#7 OFFLINE   B-ZaR

B-ZaR

    A Commando

  • Supporter
  • 1534 posts
  • Local time: 06:40 PM
  • LocationFinland

Posted 06 May 2011 - 06:18 AM


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:
g++ main.cpp

If you have several source files you do:
g++ main.cpp other.cpp yetanother.cpp

To link with a library (SDL in this example):
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.
"Things should be simple by default, customizable by preference and changeable by design."
Three Golden Lessons of the Pandora project: 1. Never assume, 2. No news is no news, 3. Something can go wrong

Currently working on: glhck
On hold: Wars | GameNode | Panorama | PNDManager | Space Rocks! | EngineWorks | QMLON
Finished: Wars: Commando

#8 OFFLINE   pmprog

pmprog

    www.pmprog.co.uk

  • Members
  • PipPipPip
  • 1558 posts
  • Local time: 04:40 PM
  • LocationCheshire, UK

Posted 07 May 2011 - 10:12 AM

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
pmprog.pngpandora.pngbutton-small.pngtournamenthub.pnggithub.png

#9 ONLINE   Letalis Sonus

Letalis Sonus

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • Local time: 05:40 PM

Posted 07 May 2011 - 12:23 PM

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.

#10 OFFLINE   Kosmos

Kosmos

    Advanced Member

  • Members
  • PipPipPip
  • 203 posts
  • Local time: 11:40 AM
  • LocationMichigan

Posted 20 April 2012 - 04:40 PM

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?

# unaBashedly -- Bourne Again!


#11 ONLINE   Pickle

Pickle

    Advanced Member

  • Members
  • PipPipPip
  • 875 posts
  • Local time: 10:40 AM

Posted 20 April 2012 - 07:17 PM


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.

#12 OFFLINE   Kosmos

Kosmos

    Advanced Member

  • Members
  • PipPipPip
  • 203 posts
  • Local time: 11:40 AM
  • LocationMichigan

Posted 21 April 2012 - 05:23 PM

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!


# unaBashedly -- Bourne Again!


#13 ONLINE   Pickle

Pickle

    Advanced Member

  • Members
  • PipPipPip
  • 875 posts
  • Local time: 10:40 AM

Posted 21 April 2012 - 05:51 PM

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

#14 OFFLINE   Kosmos

Kosmos

    Advanced Member

  • Members
  • PipPipPip
  • 203 posts
  • Local time: 11:40 AM
  • LocationMichigan

Posted 22 April 2012 - 01:35 AM


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?

# unaBashedly -- Bourne Again!


#15 ONLINE   slaeshjag

slaeshjag

    :รพ

  • Members
  • PipPipPip
  • 1256 posts
  • Local time: 05:40 PM
  • Location~Stockholm, Sweden

Donator

Posted 22 April 2012 - 01:41 AM

I don't have io.h on my linux system, are you sure it's part of the standard?
From eight were not to mess with empty and accounted for Between distress!
/* Fanatic C programmer */
On hold: YAPFP (yet another platformer for pandora), RPGDarnit
Ports on hold: Audacity, CUPS in a PND, btmnt
Currently working on: Muon, libdarnit

#16 OFFLINE   Kosmos

Kosmos

    Advanced Member

  • Members
  • PipPipPip
  • 203 posts
  • Local time: 11:40 AM
  • LocationMichigan

Posted 22 April 2012 - 02:13 AM

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.

# unaBashedly -- Bourne Again!


#17 ONLINE   Pickle

Pickle

    Advanced Member

  • Members
  • PipPipPip
  • 875 posts
  • Local time: 10:40 AM

Posted 22 April 2012 - 03:36 AM


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.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users