Reply
Thread Tools
Posts: 18 | Thanked: 38 times | Joined on Dec 2013 @ France
#1
Hello everybody.

I'm a new sailfish user, and I'm discovering the developpement tools available.

Does anybody know if ocaml has been ported on sailfish ? Do you think that it would be easy to install ocaml in the sailfish sdk ?

I would like to start with simple command-line programs, but the ideal would be to compile with lablqt.

Do you think that it is possible ?

Thanks !
 

The Following User Says Thank You to Chimrod For This Useful Post:
Guest | Posts: n/a | Thanked: 0 times | Joined on
#2
possibly, but it will give some challenges regarding qt.
Work is started by some guy for qt bindings, so I think that is worth while looking at.

Probably not too much work getting it setup for terminal usage only (eg, no nice GUI applications)

http://kakadu.github.io/lablqt/
 

The Following User Says Thank You to For This Useful Post:
Posts: 18 | Thanked: 38 times | Joined on Dec 2013 @ France
#3
Hello,

I saw the lablqt project and I want to give it a try on my sailfish. But I have a lot of steps to do before this. The first one is to get an ocaml compilator in the sdk in order to compile arm code.

I was curious if someone did this before, but didn't found any doc about it.
 
Posts: 18 | Thanked: 38 times | Joined on Dec 2013 @ France
#4
I finaly succed to compile an ocaml cross compiler. But it is not a easy task to do.

I've taken the ocaml source from https://github.com/bmeurer/ocaml-arm and the cross compilation script from http://www.cs.cmu.edu/~ecc/ocaml-cross-compiler.html wich need to be updated for ocaml4.0

Compiling inside mer cause difficulties as /tmp in not shared with sb2, you have to prefix all your make commands with TMPDIR=/an/accessible/path/from/sb2 and you can't install the cross compiler in /usr for the same reason.

But finaly I got it :

$ file a.out
a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=ccfd0e11c3d06277c7b6a80517552a1bb3ba3f12, not stripped

$ ./a.out
hello world from ocaml

I really don't know if it will be an easy task to link with other library, but the first steps is here !
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#5
cool
now, make an rpm package and upload to openrepos
 
Posts: 18 | Thanked: 38 times | Joined on Dec 2013 @ France
#6
Does this is a good place for the compiler ? This is cross builder compiler wich can be runned inside the mersdk and produce arm compiled code. It's not designed to be run on the phone !

I'm quite new in the sailfish universe but I think that the zypper repo is a better place the openrepo.

It's not completly satisfaisant for me however, as I could'nt install the libraries inside the scratchbox environement. (but it's working). I'll post the compilation steps here if your interested.
 

The Following User Says Thank You to Chimrod For This Useful Post:
Posts: 18 | Thanked: 38 times | Joined on Dec 2013 @ France
#7
Here is a rought guide to get the cross compiler :

Download ocaml-arm from the github project, you can get the zip here.

Get the patch and copy it inside mer.

Install and configure the native ocamlcompiler

Enter inside mer and unzip the archive :

Code:
unzip ocaml-arm-master.zip -d master
cd ~/master/ocaml-arm-master/

The compilerlibs does not exists (git does not like empty directory), you have to create it yourself

Code:
mkdir compilerlibs
./configure -prefix /usr
make world
make ocamlopt.opt
sudo make install
Install and configure the cross compiler

Good, you have ocaml in native mode. Now, we'll use this it for compiling the arm compiler :

Code:
unzip ocaml-arm-master.zip -d cross
cd ~/cross/ocaml-arm-master/
mkdir compilerlibs
patch -p1 < ~/patch.txt
./configure -prefix /usr -host armv7*-*-linux-gnueabi
mkdir ~/TEMP
TMPDIR=~/TEMP make cross
sb2 -t SailfishOS-armv7hl fakeroot make installcross
Call the commands inside scratchbox

OCaml has been compiled with reference to gcc as « sb2 -t SailfishOs gcc », and will try to compile with this command inside the scratchbox.

The solution I've found is to create a dummy script sb2 wich call the command given with arguments :

Code:
cat > sb2 <<
#!/bin/sh
shift
shift
COMMAND=$1
shift
${COMMAND} $*
EOF

chmod +x sb2
sb2 -t SailfishOS-armv7hl fakeroot cp sb2 /usr/local/bin
I would like to get a better solution, but didn't took time to look for that…

Now you can compile with Ocaml and run the program on your phone.
Attached Files
File Type: txt patch.txt (12.1 KB, 84 views)
 

The Following User Says Thank You to Chimrod For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 14:08.