How to install GCC on the Nokia N900

I finally got around to installing GCC on my Nokia N900 today (using Maemo 5). I found it more challenging than I expected so I figured it would be nice to share how I did it.

First, you’ll need root on the device. If it’s not installed it already, see the instructions for installing and using rootsh.

Next, download the packages required for GCC. These can be found with a bit of searching on the Maemo repositories page. The fremantle and maemo5.0 repositories seem to be the same. For gcc you’ll need these packages:

For g++, you’ll also need these packages:

I downloaded these packages onto my computer and copied them to my N900 via mass storage mode. If downloading them directly to your N900 is easier, you could do that.

Once you have all the packages, you can install them by logging in as root (sudo gainroot) and then running dpkg -i <package> for each package. You should be able to do this in the order listed above.

The last two g++ packages (libstdc++6-4.2-dev and g++-4.2) depend on themselves so the procedure isn’t quite as easy (you can’t dpkg -i one and then the other). First, unpack each of the packages by running dpkg --unpack <package>. Then run dpkg --configure -a. This will configure both packages at the same time. If they’re not installed yet, you can run dpkg -i <package> for each of them.

At this point, you should have gcc and (optionally) g++ installed. To invoke them, run gcc-4.2 and g++-4.2. If you like, you can add your own symlinks to run them as just gcc and g++.

After installing GCC, I compiled some trivial C and C++ applications, which ran fine. You may need to install more libraries to compile more complicated applications. You should be able to find such libraries by browsing the fremantle repository.

I’ve tried adding http://repository.maemo.org/ as a repository in “App. manager”, but it failed to find packages, which is why I installed them manually as described above. If you know of a way to make that method work, let me know; it would be much cleaner.

Also let me know If I missed any required packages or have the dependencies out of order.

I could have installed the Maemo SDK on my computer using these instructions, but I prefer to have my development environment right on the device so it is always available when I have my device. To use a nicer keyboard, I can SSH into my N900 from any computer with a full-sized keyboard (not just one with the Maemo SDK installed).

Now that GCC is installed, it’s time to compile tangoGPS, my favorite GPS tracing tool, for Maemo 5. Hopefully I’ll have some results to post soon.

37 Responses to “How to install GCC on the Nokia N900”


  • Hi,

    have a look for the dependencies here:
    http://packages.debian.org/lenny/tangogps

    AFAIK there is no gpsd on maemo 5? The other day I had a look into this and someone pointed me to some maemo gps api. If you want help, let me know.

    marcus

  • Maemo’s GPS library appears to be liblocation. The API documentation is here:

    http://maemo.org/api_refs/5.0/5.0-final/liblocation/

    The LocationGPSDeviceFix section is particularly interesting. It seems to give you the actual location information:

    http://maemo.org/api_refs/5.0/5.0-final/liblocation/LocationGPSDevice.html#LocationGPSDeviceFix

    Some of the documentation alludes to gpsd, but I’m not sure if Maemo has it or, if it does, whether you can access it in the usual way.

    I’ll look into this further when I get some time. Hopefully it will be straight-forward to port tangoGPS to liblocation if we need to go that route.

  • eCoach, a popular GPS tracing tool for Maemo, might be useful for learning how liblocation works. The source code is here:

    http://repository.maemo.org/extras/pool/fremantle/free/source/e/ecoach/ecoach_1.56.tar.gz

    You can find the main eCoach web site here:

    http://ecoach.garage.maemo.org/

  • Hello ossguy,

    Marcus have linked me to your Site. I love tangogps for my Openmoko Neo Freerunner and i hope you get it working on Maemo5, too 🙂

    with kind regards

    Patrick

  • To avoid unpacking the last two packages, you can simply install both packages in one command, simply doing

    dpkg -i

    So a much faster way is to put all packages in an empty directory and do

    dpkg -i *.deb

    This will install everything.

  • Hi Denver,
    Congrats for porting.
    I don’t have a N900, does it have any make utility installed?
    Thanks & regards,
    MC

  • No, not by default. It’s available from the repository I discussed, though:

    http://repository.maemo.org/pool/fremantle/free/m/make/make_3.80-9osso_armel.deb

    Just download that .deb and run dpkg -i on it to get make. I haven’t had a chance to test it myself, but it’s very likely to work the same as GCC did (and it doesn’t seem to have any dependencies).

  • Hello,

    Much thanks for the tutorial 🙂 I installed it successfully, but when I try to run the compiled program, I get a “permission denied” error, even after executing “chmod +x” on the file. Any ideas how to solve that?

  • Mazen: did you try something like “chmod 666 “or even “chmod 777 ” ?

  • Eduard, I also tried that but it didn’t work. In fact, it seems that chmod doesn’t change file permissions at all (even when executed as root). I’m digging into it..

  • have you any knowledge on porting Zfone to N900…seems ip_queue module isn’t being all that easy to configure/set – can you assist?
    cheers ian

  • try “sh ./configure” and you won’t get permission denied error. anyway i get other errors instead, something about “host not specified” and “no cc founded” :S what about these?ì?

  • Hi! I’m not an expert in maemo so I have a problem. When i try to:

    dpkg -i gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb

    it stops with message:

    dpkg: error processing gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb (–install):
    unable to create `./usr/share/doc/gcc-4.2-base/changelog.Debian.gz’: No such file or directory
    dpkg-deb: subprocess paste killed by signal (Broken pipe)
    Errors were encountered while processing:
    gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb

    What does it seems to mean?

  • @ossguy Thx for How To

    @Mazen compile your Source to another location for example /opt/ because the default Folder ‘MyDocs’ is a FAT Partition. Now you are able to change the rights of your compiled File by using chmod.

  • Let me answer the question for meeting “permission denied” problem when your want to run a compiled file.

    You probably compile your file under “MyDocs” folder.
    Since “MyDocs” is mounted as FAT32 filesystem.
    FAT32 doesn’t support permissions, and it’s probably mounted as noexec too.
    You should make a dir under /home/user directly, copy your source files and compile them under the new folder.

    Then your compiled file will run normally 🙂

  • i installed the gcc-4.2 using dpkg -i *
    and installation was successful.
    i tried to compile a hello.c which is in /home/user/ using this command:

    gcc-4.2 -o hello hello.c

    and i get these errors:
    stdio.h no such file or directory
    implicit declaration if ‘printf’

    does this mean i have to install build-essentials, dpkg-dev, etc..
    any hints ?
    thanks

  • Hi

    I am having the same problem as Raed A, Installed gcc fine, but when i try to compile any program even stuff as simple as hello.c, i get the same error.

    Anyone have any ideas?

    Thanks

  • Hi

    Ok i have figured out the problem, the first 2 packages from the “optional” list have to be installed, That is Linix-Kernel-Headers, and Libc6-dev. In that order.

    Then you will have no problems compileing.

  • thanks a lot DataStream, good spot. it worked for me..

  • hi all,

    I install gcc 4.2 in my mobile successfully. After that I write a simple program I compile it using “gcc-4.2 c.c” it compile successfully but I try to run the out file (./a.out)it getting error “permission denied” please help me i tred chmod 777 ./a.out but no use please help me

    thanks

  • try to use : gcc-4.2 -o hello hello.c
    and to run it type ./hello

  • You could just add the following repo

    deb http://repository.maemo.org/ fremantle/sdk free

    and do: “apt-get install build-essential”

    from:
    http://wiki.maemo.org/User:Jebba/Repositories

  • Hi,

    Used this for hacking for ages – found after update to PR1.2 that the libc-dev version was incorrect, need to replace the one (20) suggested:

    http://repository.maemo.org/pool/fremantle/free/g/glibc/libc6-dev_2.5.1-1eglibc20+0m5_armel.deb

    with the following (25):

    http://repository.maemo.org/pool/fremantle/free/g/glibc/libc6-dev_2.5.1-1eglibc25+0m5_armel.deb

    All good again!

  • thanx for the update of libc6-dev…i was going post it. this is the reason i revisited the site

  • Can any of you kind people give me an idea of how much root space installing all this will take ? I’m assuming it’s not optified ?

    Thanks.

  • how to compile cpp programs using gcc-4.2 in nokia N900

  • to VIMES: i am not sure out the size occupies these libraries, but y would u worry about size ? i dont think is much.

    to SRINIVASU:
    as mentioned above u have to install g++ as mentioned in the second step. then type : g++ or g++4.2 test.cpp

  • Use SDK repo for installing make gcc cpp g++ etc…
    http://repository.maemo.org/

  • thanks for the awesome how to
    i have always been prety computer literate but have just started a software engineering degree so i have just started getting into the guts of the unix world.

    I have a c class n i got this working but ssl would be awesome when im at home can anyone tell me does the n900 come with ssl?
    i try type it in terminal and i get -sh : ssl: not found
    if it doesnt can anyone tell me or point me toward a good guide to get it to work?

    all of my programs i write for this class have to compile n run on mac osx.. r there any major differences between compiling on n900 and the macs?

    thanks

  • Hi

    Are there any way to compile .c in vm virtualbox and copy into n900?

    I hate install libs for one use.

  • Hi,
    When I try to install gcc on my nokia n900, errors are shown. could anyone help me.
    error below.
    ———————————————————————–
    /home/user/MyDocs/Software/Gcc # ls
    binutils_2.18.50.20070820-4+0m5_armel.deb
    cpp-4.2_4.2.1-4maemo9+0m5_armel.deb
    gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb
    gcc-4.2_4.2.1-4maemo9+0m5_armel.deb
    libgcc1_4.2.1-4maemo9+0m5_armel.deb
    libgomp1_4.2.1-4maemo9+0m5_armel.deb
    /home/user/MyDocs/Software/Gcc # dpkg -i binutils_2.18.50.20070820-4+0m5_armel.deb
    (Reading database … 32366 files and directories currently installed.)
    Preparing to replace binutils 2.18.50.20070820-4+0m5 (using binutils_2.18.50.20070820-4+0m5_armel.deb) …
    Unpacking replacement binutils …
    Setting up binutils (2.18.50.20070820-4+0m5) …
    /home/user/MyDocs/Software/Gcc # dpkg -i libgcc1_4.2.1-4maemo9+0m5_armel.deb
    (Reading database … 32366 files and directories currently installed.)
    Preparing to replace libgcc1 1:4.2.1-4maemo9+0m5 (using libgcc1_4.2.1-4maemo9+0m5_armel.deb) …
    Unpacking replacement libgcc1 …
    Setting up libgcc1 (1:4.2.1-4maemo9+0m5) …
    /home/user/MyDocs/Software/Gcc # dpkg -i libgomp1_4.2.1-4maemo9+0m5_armel.deb (Reading database … 32366 files and directories currently installed.)
    Preparing to replace libgomp1 4.2.1-4maemo9+0m5 (using libgomp1_4.2.1-4maemo9+0m5_armel.deb) …
    Unpacking replacement libgomp1 …
    Setting up libgomp1 (4.2.1-4maemo9+0m5) …
    /home/user/MyDocs/Software/Gcc # dpkg -i cpp-4.2_4.2.1-4maemo9+0m5_armel.deb
    (Reading database … 32366 files and directories currently installed.)
    Preparing to replace cpp-4.2 4.2.1-4maemo9+0m5 (using cpp-4.2_4.2.1-4maemo9+0m5_armel.deb) …
    Unpacking replacement cpp-4.2 …
    Setting up cpp-4.2 (4.2.1-4maemo9+0m5) …
    /home/user/MyDocs/Software/Gcc # dpkg -i gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb
    (Reading database … 32366 files and directories currently installed.)
    Preparing to replace gcc-4.2-base 4.2.1-4maemo9+0m5 (using gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb) …
    Unpacking replacement gcc-4.2-base …
    Replaced by files in installed package gcc-4.2 …
    dpkg: error processing gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb (–install):
    unable to create `./usr/share/doc/gcc-4.2-base/changelog.Debian.gz’: No such file or directory
    Errors were encountered while processing:
    gcc-4.2-base_4.2.1-4maemo9+0m5_armel.deb
    /home/user/MyDocs/Software/Gcc #

  • i am having the same problem.. 🙁

  • If you add:

    deb http://repository.maemo.org/ fremantle/sdk free non-free
    deb http://repository.maemo.org/ fremantle/tools free non-free

    to your APT sources, you will be able to install gcc (or even build-essential!) through apt-get

  • Hi,

    This article helps a lot.

    Thanks.

  • Hi
    Thank you so much.
    very useful tutorial.

  • i tried but its saying …..
    errors were encounterd wile processing
    libc6-dev
    libstdc++6-4.2-dev
    g++-4.2

    any one with any suggestion?

Leave a Reply to ossguy