| Prev |   1   2   3   | Next
maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   On-device development in C/C++? (https://talk.maemo.org/showthread.php?t=34412)

endboss 2010-01-24 16:24

Re: C/C++ program for n900
 
Quote:

Originally Posted by CharlesM (Post 491609)
Do I really need all of this to compile simple command line progs?

For compiling small programs it is absolutly sufficient to install gcc [~9MB] and g++ (if needed) [~14MB] only. No build-essential and all that stuff. If you have no other unoptified stuff installed you should have no problems installing those packages. I did that, I have enough space left and for small on device compiling I have all I need.

daperl 2010-01-24 16:38

Re: C/C++ program for n900
 
Quote:

Originally Posted by nicola.mfb (Post 491765)
Hi, it may be interesting to put the sdk on an external microSD (like debootstrap but with maemo and sdk repositories), use chroot to develop and copy the results on the real OS.
Some hints for that?

This is a great idea. If someone doesn't pick this up before me I'll definitely go this route when I get back to this stuff. Unfortunately, my schedule is screwed for the next 3 weeks. In the meantime, just because, here are some instructions to get an SD card rollin':

Maybe choose a Class 6 from this page. I recently purchased this one. Then:

Turn off
Insert microSD card in n900
Turn on
And as root in an xterminal, type the following:

WARNING: Same as above

sfdisk /dev/mmcblk1 << EOS
,100,b***
,3900,L
,,L
EOS
# be patient and wait for the prompt to come back
mkfs.vfat /dev/mmcblk1p1
mkfs.ext3 /dev/mmcblk1p2
mkfs.ext3 /dev/mmcblk1p3
mkdir -p /mnt/mmc12
mount -t ext3 -o noatime,data=writeback /dev/mmcblk1p2 /mnt/mmc12
mount / /floppy
cp -a /floppy /mnt/mmc12/.chroot
# Be even more patient

The next step would be either the big post above (with a tiny list of other things) or a debian installer to be named later :eek:.

Quote:

Originally Posted by CharlesM (Post 491609)
Do I really need all of this to compile simple command line progs?

You don't need to do everything from the big post to get simple compiling going. After you get to the package install step, just install build-essential:

apt-get install build essential

Then you should be able to:

gcc mybiitchinapp.c -o mybiitchinapp

***This has a side effect (possibly bad) of letting certain programs think this vfat area is an archive space. I left it in because I think it makes booting from an SD card less painful (if one were to decide to go that route), but don't quote me on that.

nicola.mfb 2010-01-30 15:53

Re: C/C++ program for n900
 
Ok, I managed to have a nice SDK partition, here some hints:

* mmcblk1p1 (or another sd partition) formatted and mounted on /sdk
* extract maemo-sdk-rootstrap_5.0_armel.tgz to /sdk
* create dev and mount it from real dev with mount -o bind
* mount /sdk/dev/pts, /sdk/proc and /sdk/sys properly (not sure about the last two, the first is necessary to avoid apt-get errors)
* add to /etc/apt/sources.list the line:
Code:

deb http://repository.maemo.org/ fremantle/xxxxx nokia-binaries
replace xxxxx with the exact string from your scratchbox installation.

That's all, I just checked out a my qt4 project and compiled with:

* chroot /sdk
* apt-get update
* apt-get install libqt4-dev
* cd blah
* qmake
* make

Please test and elaborate the above instruction, and provide further hints to have all automounted and working at device boot :)

Regards

Niko

jaeezzy 2010-02-07 09:26

Re: C/C++ program for n900
 
Quote:

Originally Posted by nicola.mfb (Post 502640)
Ok, I managed to have a nice SDK partition, here some hints:

* mmcblk1p1 (or another sd partition) formatted and mounted on /sdk
* extract maemo-sdk-rootstrap_5.0_armel.tgz to /sdk
* create dev and mount it from real dev with mount -o bind
* mount /sdk/dev/pts, /sdk/proc and /sdk/sys properly (not sure about the last two, the first is necessary to avoid apt-get errors)
* add to /etc/apt/sources.list the line:
Code:

deb http://repository.maemo.org/ fremantle/xxxxx nokia-binaries
replace xxxxx with the exact string from your scratchbox installation.

That's all, I just checked out a my qt4 project and compiled with:

* chroot /sdk
* apt-get update
* apt-get install libqt4-dev
* cd blah
* qmake
* make

Please test and elaborate the above instruction, and provide further hints to have all automounted and working at device boot :)

Regards

Niko

Hi niko,
I would be very grateful if you could kindly elaborate each step and kinda make it step by step guide for biginners/average users. I have managed to install build-essential and gtk+ on the device itself and looking to finally get the maemo sdk and figured out, from what I saw here, is quite a bit of work for average user like me. Also agreed that its good to have it separately from the OS. Thank you.

P.S However isn't it possible to just install the packages required to compile hildon applications. thanks

madmaze 2010-02-11 16:06

developing apps directly on the n900 with c
 
hello everyone,
is there a way i can compile and and develop directly on the n900?
ive tried to apt-get install gcc g++
but it tells me there is no installable candidate..

can anyone point me in the right direction?

verhagke 2010-02-11 16:25

Re: developing apps directly on the n900 with c
 
I don't believe that a compiler has been ported yet

Rob1n 2010-02-11 16:31

Re: developing apps directly on the n900 with c
 
See this thread which seems to have covered the same question.

alex94 2010-02-16 12:33

Re: C/C++ program for n900
 
Quote:

Originally Posted by endboss (Post 492059)
For compiling small programs it is absolutly sufficient to install gcc [~9MB] and g++ (if needed) [~14MB] only. No build-essential and all that stuff. If you have no other unoptified stuff installed you should have no problems installing those packages. I did that, I have enough space left and for small on device compiling I have all I need.

How have you installed GCC?
I tried this but it doesn't work:
$ sudo gainroot
$ apt-get install gcc

Thanks

endboss 2010-02-17 12:34

Re: C/C++ program for n900
 
Quote:

Originally Posted by alex94 (Post 529404)
How have you installed GCC?
I tried this but it doesn't work:
$ sudo gainroot
$ apt-get install gcc

Thanks

You probably didn't add the sources.
Edit /etc/apt/sources.list and add the following line to it:
deb http://repository.maemo.org fremantle/sdk free non-free
The fastest way to accomplish this is like this:
echo "deb http://repository.maemo.org fremantle/sdk free non-free" >> /etc/apt/sources.list
Afterwards type apt-get update. Now the installation should work.

alex94 2010-02-17 16:39

Re: C/C++ program for n900
 
Thanks enboss gcc is now on my machine.
I can compile C files, but how can i execute them?
I tried:
$ sudo gainroot
$ ./test
Error is: Permission denied
So i tried:
$ sudo ./test
but this doesn't work too :(

sjgadsby 2010-02-17 16:42

Re: C/C++ program for n900
 
The thread "developing apps directly on the n900 with c" with three posts has been merged into this thread.

Lehto 2010-02-17 16:45

Re: C/C++ program for n900
 
Quote:

Originally Posted by alex94 (Post 532504)
Thanks enboss gcc is now on my machine.
I can compile C files, but how can i execute them?
I tried:
$ sudo gainroot
$ ./test
Error is: Permission denied
So i tried:
$ sudo ./test
but this doesn't work too :(

sudo gainroot
chmod 777 test
./test

EDIT: chmod only needs to be done once.

bugelrex 2010-02-17 16:55

Re: On-device development in C/C++?
 
How safe is this considered to be. Any issues with
- disk space with future firmwares
- overwriting any existing libraries thus causing incompatibilies/stability. I'm assuming its not just the gcc binary that gets downloaded, but a bunch of dependencies too

alex94 2010-02-17 18:11

Re: On-device development in C/C++?
 
I got still the error permission denied :/
chmod seams to be corrupt.

endboss 2010-02-17 18:43

Re: On-device development in C/C++?
 
Quote:

Originally Posted by alex94 (Post 532668)
I got still the error permission denied :/
chmod seams to be corrupt.

I assume you are working somewhere below the MyDocs directory. Go into /home/user and create there a new folder if you wish. The MyDocs folder is a vfat partition and does not allow executables. chmod will fail there because it's not a linux partition.

bugelrex 2010-02-17 22:08

Re: On-device development in C/C++?
 
to have only gcc, I edited sources.list and did apt-get install gcc

but it can't find stdio.h and I also get a link error of crt1.o no such file.

What other dependencies are needed? how much more is this going to bloat to?

codeMonkey 2010-02-18 09:37

Re: On-device development in C/C++?
 
Quote:

Originally Posted by bugelrex (Post 533134)
to have only gcc, I edited sources.list and did apt-get install gcc

but it can't find stdio.h and I also get a link error of crt1.o no such file.

What other dependencies are needed? how much more is this going to bloat to?

If you want a full development environment, probably quite a bit.

I run an SDK in a chroot. Qole is hosting an image here.
You can install the easy-chroot scripts and run it without having to worry about bloating your rootfs or installing things on the device that might cause problems with busybox.

DaveR53 2010-02-18 16:52

Re: On-device development in C/C++?
 
This is awesome, just got it set up on my n900. Good work chaps/chapettes! Just compiled my own small game directly on the phone. :D

kleimola 2010-02-19 13:41

Re: On-device development in C/C++?
 
Quote:

Originally Posted by codeMonkey (Post 533887)
I run an SDK in a chroot. Qole is hosting an image here.
You can install the easy-chroot scripts and run it without having to worry about bloating your rootfs or installing things on the device that might cause problems with busybox.

A few questions. Assume I have an empty MicroSDHC card, should I prepare it with ext3 as told earlier in this thread and then somehow mount the above ext2 image on it or? Could you give some short guidelines how you mount the image on the card so that the development can be made there and which easy-chroot scripts you then run to use it?

Thanks for any help!

DaveR53 2010-02-19 14:02

Re: On-device development in C/C++?
 
I just followed this... http://talk.maemo.org/showpost.php?p...5&postcount=19 works a treat :)

codeMonkey 2010-02-19 15:44

Re: On-device development in C/C++?
 
Currently I'm doing it in the same way that that post says. Running it from a file, rather than a separate partition.
Qole also has an easy-chroot guide here.

kleimola 2010-02-19 20:15

Re: On-device development in C/C++?
 
Quote:

Originally Posted by DaveR53 (Post 536578)
I just followed this... http://talk.maemo.org/showpost.php?p...5&postcount=19 works a treat :)

Thanks, I got it working. I'd like to try Qt 4.6 development on the device, but I wonder if there are any ARM version of libqt4-maemo5-dev around?

DaveR53 2010-02-19 22:08

Re: On-device development in C/C++?
 
I've been messing around today trying to get a nice dev enviroment setup. I connect it on usb to my FreeBSD desktop and enable PC Suite Mode so that the USB networking starts, then set an ip on the usb0 interface on the N900 and one on my desktop.

Use sshfs on my desktop to mount the home folder locally so I can use my text editor (NEdit) on a sensible keyboard to edit/hack source. And also have open an ssh session to the n900 for compiling in the qchroot.

Perfect, it's just like working locally on my desktop :D

Its a surprisingly nippy little machine, a lot quicker at compiling than I thought it would be and with this setup its way more convienient than working with the SDK in a VM. Compile directly on the device and then run it.

kleimola 2010-02-20 15:21

Re: On-device development in C/C++?
 
Quote:

Originally Posted by kleimola (Post 537216)
Thanks, I got it working. I'd like to try Qt 4.6 development on the device, but I wonder if there are any ARM version of libqt4-maemo5-dev around?

This is odd. apt-getting libqt4-maemo5-dev from extras-devel seems to install libqt4-maemo5-dev_4.6.2~git20100212-0maemo1_armel.deb but the installed /opt/qt4-maemo5/qmake is still i386 binary and not ARM like in libqt4-dev (version 4.5.3). Has anyone got this working yet?

codeMonkey 2010-02-23 18:22

Re: On-device development in C/C++?
 
The versions that are installed in scratchbox armel seem to work.
Try step 7 of the instructions in this section of the wiki.
You'll need to add the source line that you get back after accepting the EULA to your /etc/apt/sources.list within the chroot.
Then run apt-get update and apt-get install libqt4-dev.

kleimola 2010-02-23 18:57

Re: On-device development in C/C++?
 
Quote:

Originally Posted by codeMonkey (Post 543056)
Then run apt-get update and apt-get install libqt4-dev.

Yes, the libqt4-dev works, which is qt 4.5.3, but libqt4-maemo5-dev does not (qt 4.6.2 currently). There is no ARM binaries for that package as answered on qt-maemo-feedback mailing list:

http://lists.trolltech.com/pipermail...ry/000074.html

I wonder who provided the ARM binaries for libqt4-dev? Perhaps it could be possible to cross-compile libqt4-maemo5-dev as well.

fred123 2010-02-26 21:15

Re: On-device development in C/C++?
 
Trying to compile a program on n900, getting error from .configure.

Code:

gcc (GCC) 4.2.1
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2731: $? = 0
configure:2733: gcc -v </dev/null >&5
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --disable-libssp --disable-sjlj-exceptions --disable-multilib --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.2.1
configure:2736: $? = 0
configure:2738: gcc -V </dev/null >&5
gcc: '-V' option must have argument
configure:2741: $? = 1
configure:2764: checking for C compiler default output file name
configure:2767: gcc    conftest.c  >&5
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure:2770: $? = 1
configure: failed program was:
| /* confdefs.h.  */

I have apt-get install gcc, what else do I need?

fred123 2010-02-26 21:34

Re: On-device development in C/C++?
 
OK found problem!
apt-get install libc6-dev

All working

wannessmet 2010-08-17 11:04

Re: On-device development in C/C++?
 
@ lcuk

I followed your instructions but while trying to configure (ipmitool)

Code:

Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# PATH=$PATH:. ;
Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# sh ./configure
checking build system type... armv7l-unknown-linux-gnu
checking host system type... armv7l-unknown-linux-gnu
checking target system type... armv7l-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# checking for gawk... no

Do you have any idea what's going wrong?


nicolai 2010-08-17 11:11

Re: On-device development in C/C++?
 
checking whether the C compiler works... configure: error: cannot run C compiled programs.
Don't do this from within you MyDocs folder.
It is on a partitition which is formatted as VFAT
and you can not run executables from there.
Put your ipmitool-1.8.11 to
/home/user/
for example and try again.
Nicolai

lcuk 2010-08-17 11:13

Re: On-device development in C/C++?
 
Quote:

Originally Posted by wannessmet (Post 789186)
@ lcuk

I followed your instructions but while trying to configure (ipmitool)

Code:

Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# PATH=$PATH:. ;
Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# sh ./configure
checking build system type... armv7l-unknown-linux-gnu
checking host system type... armv7l-unknown-linux-gnu
checking target system type... armv7l-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
Nokia-N900-51-1:/home/user/MyDocs/Downloads/ipmitool-1.8.11# checking for gawk... no

Do you have any idea what's going wrong?



Yes, you did not read everything I said.


Quote:

Originally Posted by lcuk (Post 375916)

note, this doesnt bring in autotools or dpkg
so no ./configure stage works, and no dpkg-buildpackage will run.
(normal make files and find an alternative for packaging)

if you don't need them and can work with makefiles its certainly usable and fast.
if you need -dev headers for libraries, expect even more space, I find nowadays I can get by mostly with libliqbase-dev

hth

So, I could not get this to work but did not need it.
If you investigate the error itself there is potential to get past it.

clasificado 2010-08-17 11:16

Re: On-device development in C/C++?
 
thats a very common error when preparing an n900 development environment of the device itself.

put your source inside the chroot image or inside /home/user.

in other words, dont try to compile from /home/user/MyDocs, because its FAT32. Or mess with ./configure to let you compile outside the source folder.

thats because with fat32 you dont get the execution bit.

clasificado

lcuk 2010-08-17 11:20

Re: On-device development in C/C++?
 
Quote:

Originally Posted by nicolai (Post 789191)
checking whether the C compiler works... configure: error: cannot run C compiled programs.
Don't do this from within you MyDocs folder.
It is on a partitition which is formatted as VFAT
and you can not run executables from there.
Put your ipmitool-1.8.11 to
/home/user/
for example and try again.
Nicolai

hey Nicolai,
hmm last time I tried the configure stage would fail with anything, but you are certainly more confident than myself that it should work!
this is great if so and removes one block from the way :)

it would be best of all if we could optify these build-essential packages and get dpkg-buildpackage working happily.

nicolai 2010-08-17 11:45

Re: On-device development in C/C++?
 
I must admit, I don't know if the whole configure stage work.
I am working with plain old hand written Makefiles.

Nicolai

lcuk 2010-08-17 11:49

Re: On-device development in C/C++?
 
Quote:

Originally Posted by nicolai (Post 789220)
I must admit, I don't know if the whole configure stage work.
I am working with plain old hand written Makefiles.

Nicolai

Makefiles are elegant weapons... for a more civilized age
http://xkcd.com/297/


they work well!
I have just made libliqbase work on x86 with the ones there :)

wannessmet 2010-08-17 12:03

Re: On-device development in C/C++?
 
Solved: I adapted the /etc/fstab. The home partition where I was building the software was mounted as noexec. I removed that option and it was working :)

norayr 2011-01-08 14:02

Re: On-device development in C/C++?
 
I also prefer to compile on device, and that's my manual, how to do that with FreePascal

virusforu 2011-07-08 16:22

Re: On-device development in C/C++?
 
C Programming on Maemo Device (N 900): Mobile C programming lab :cool:
Download the following files to work with gcc
• binutils_2.18.50.20070820-4+0m5_armel.deb
• libgcc1_4.2.1-4maemo9+0m5_armel.deb
• libgomp1_4.2.1-4maemo9+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
1. connect your N900 to PC and copy above files into one folder
~ $ cd ~/MyDocs //change to this folder in N900 in xterm
~/MyDocs $ cd files //here your above files are copied
~/MyDocs/files $ dpkg –i * // to run all the files in files folder
~/MyDocs/files $ vi hellowrold.c //create a c program by using vi editor
Note : for entering any letter you should press “I” to enter in to insert mode
#inlcude <stdio.h>
main()
{
Printf(“M. Reddi Prasad Reddy,IP University,Delhi”);
}
Note: to save the files click ESC and shift+: and wq! .so that your c program will be saved.
~/MyDocs/files $ gcc-4.2 hello.c // gcc compiler will compile your c program
~/MyDocs/files $ ls // you will find the output file
a.out hello.c
~/MyDocs/files $ sudo gainroot //shell root will be enabled
~home/usr/MyDocs/files # cp a.out /usr/bin // to see the output you should copy this outputfile to bin folder
~/usr/bin # chmod +x a.out // change the permissions
~/usr/bin # ./a.out
M. Reddi Prasad Reddy,IP University,Delhi


any other ideas and comments
Mail id: reddy.mrp@gmail.com

Joorin 2011-07-08 17:09

Re: On-device development in C/C++?
 
Quote:

Originally Posted by virusforu (Post 1047165)
~/MyDocs/files $ vi hellowrold.c //create a c program by using vi editor

Weird spelling of the file name. Especially as you're trying to compile hello.c later on.

Quote:

Note : for entering any letter you should press “I” to enter in to insert mode
#inlcude <stdio.h>
main()
{
Printf(“M. Reddi Prasad Reddy,IP University,Delhi”);
}
Note: to save the files click ESC and shift+: and wq! .so that your c program will be saved.
It's spelled "include". The function you're looking for is "printf".

ESC leaves insertion mode. The command to save and quit is "wq" by itself and one enters command mode using ":".

Quote:

~/MyDocs/files $ gcc-4.2 hello.c // gcc compiler will compile your c program
~/MyDocs/files $ ls // you will find the output file
a.out hello.c
Use -o flag to give the generated binary a name.

Quote:

~/MyDocs/files $ sudo gainroot //shell root will be enabled
~home/usr/MyDocs/files # cp a.out /usr/bin // to see the output you should copy this outputfile to bin folder
~/usr/bin # chmod +x a.out // change the permissions
~/usr/bin # ./a.out
Why copy the binary to /usr/bin to then run it using ./a.out ?

virusforu 2011-07-08 18:05

Re: On-device development in C/C++?
 
Corrected POST: Thank you JOORIN for your comments
~ $ cd ~/MyDocs //change to this folder in N900 in xterm
~/MyDocs $ cd files //here your above files are copied
~/MyDocs/files $ sudo gainroot //shell root will be enabled
~home/usr/MyDocs/files # dpkg –i * // to run all the files in files folder
~home/usr/MyDocs/files # vi hello.c //create a c program by using vi editor
Note : for entering any letter you should press “I” to enter in to insert mode

#include <stdio.h>
main()
{
Printf(“M. Reddi Prasad Reddy,IP University,Delhi”);
}

Note:ESC leaves insertion mode. The command to save and quit is "wq" by itself and one enters command mode using ":".
~home/usr/MyDocs/files # gcc-4.2 hello.c // gcc compiler will compile your c program
~home/usr/MyDocs/files # ls // you will find the output file
a.out hello.c

~home/usr/MyDocs/files # cp a.out /usr/bin // to see the output you should copy this outputfile to bin folder
~/usr/bin # chmod +x a.out // change the permissions
~/usr/bin # ./a.out
M. Reddi Prasad Reddy,IP University,Delhi


I have modified the post. this can help people little
i have saved the a.out to /usr/bin to execute otherwise its not able to get the permissions.:confused:
Q: but still some other N900 devices are not able to install gcc.:confused:


| Prev |   1   2   3   | Next
All times are GMT. The time now is 08:42.

vBulletin® Version 3.8.8