axiles / ocaml-efl

An OCaml interface to the Enlightenment Foundation Libraries (EFL) and Elementary
https://forge.ocamlcore.org/projects/ocaml-efl/
Other
27 stars 4 forks source link

difficulties for building examples #4

Closed cedlemo closed 8 years ago

cedlemo commented 8 years ago

Hi,

I am just starting learning Ocaml so don't be too harsh. :)

I have installed ocaml-efl via opam and I wanted to try the different examples. So I have locally cloned you repos (I use ArchLinux x86-64) read the README, and tried this:

ocamlbuild -use-ocamlfind -pkg efl an_example.byte

or

 ocamlbuild -use-ocamlfind -pkg efl an_example.native

Both have failed. After that I have read the issue #1 that says that the examples are built when the user build the bindings. In the INSTALL file it is said to launch the ./configure command but there is no configure file in the root directory.

Nevermind, I added one autoconf.sh just to see but even if I was able to generate a configure file, I was not able to build.

As I said previously I am just starting with Ocaml, but I really want to try your bindings.

Regards

axiles commented 8 years ago

Hi,

For compiling from the git repo, you have to generate the files './configure', 'Makefile.in', etc...

You can do this by just running 'autoreconf -i'. The will run autoconf, automake, etc... in the correct order. Of course, you need to have autoreconf installed.

For simplicity, I have just added a file './autogen.sh' which just call autoreconf.

The command:

'ocamlbuild -use-ocamlfind -pkg efl an_example.byte'

can only be run once ocaml-efl have been installed (after 'make install')

cedlemo commented 8 years ago

Thanks for helping me. I have the same problems, what I have done:

./autogen.sh
./configure
make

The make command generated a lot of errors that you can see here: https://gist.github.com/cedlemo/32493ab0915734edd040#file-ocaml-efl-make-log

I was able to install the libs:

sudo make install
Mot de passe [sudo] de cedlemo :
Installed /usr/local/lib/ocaml/4.02.3/efl/efl.a
Installed /usr/local/lib/ocaml/4.02.3/efl/libefl_stubs.a
Installed /usr/local/lib/ocaml/4.02.3/efl/dllefl_stubs.so
Installed /usr/local/lib/ocaml/4.02.3/efl/efl.cmxs
Installed /usr/local/lib/ocaml/4.02.3/efl/efl.cmxa
Installed /usr/local/lib/ocaml/4.02.3/efl/efl.cmi
Installed /usr/local/lib/ocaml/4.02.3/efl/efl.cma
Installed /usr/local/lib/ocaml/4.02.3/efl/META
Updated /usr/lib/ocaml/ld.conf

But I am not able to build one of your example:

cd examples
ocamlbuild -use-ocamlfind -pkg efl bubble_example_01.byte
+ ocamlfind ocamlc -linkpkg -package efl bubble_example_01.cmo -o bubble_example_01.byte
ocamlfind: Package `efl' not found
Command exited with code 2.
Hint: Recursive traversal of subdirectories was not enabled for this build,
  as the working directory does not look like an ocamlbuild project (no
  '_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
  you should add the option "-r" or create an empty '_tags' file.

  To enable recursive traversal for some subdirectories only, you can use the
  following '_tags' file:

      true: -traverse
      <dir1> or <dir2>: traverse

Compilation unsuccessful after building 3 targets (2 cached) in 00:00:00.
axiles commented 8 years ago

Sorry, I did not see you installed ocaml with opam.

First, clean up what you did: sudo make uninstall make distclean

Now, do: ./configure --prefix=$(opam config var prefix) OCAMLFIND_DESTDIR=$(opam config var lib) make make examples # This should build all the examples make install # By default, your opam directory is inside $HOME and you don't need sudo

NB1: Apparently, the log you posted for 'make' only contained warnings, and no errors. What is surprising, is that is that it also gives warnings in the EFL headers. How did you installed the EFL/Elementary ? By compiling the sources or by your package manager ?

NB2: There is an opam package available for the EFL, but its a few months old. However, there has been a new release today, and the opam package should be available in a few days.

NB3: This is a general remark about ocamlbuilld. Don't run ocamlbuild in a subdirectory of a directory where ocamlbuild has already been runed. If you want to test: 'ocamlbuild -use-ocamlfind -pkg efl something.byte' you should create a fresh directory (for example ~/test_ocaml_efl) and copy/write the .ml files in it.

cedlemo commented 8 years ago

The make command works, but I have an error with the make examples

make examples
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlc.opt -I src -dllpath _build/src -dllpath /home/cedlemo/.opam/system/lib/stublibs -dllib -lefl_stubs -cclib '-lelementary -lefl -leina -lpthread -leet -levas -lecore -lecore_evas -lecore_file -lecore_input -ledje -leo -lethumb_client -lemotion -lecore_imf -lecore_con -leldbus -lefreet -lefreet_mime -lefreet_trash -leio -ldl -lm' src/efl.cmo examples/actionslider_example_01.cmo src/libefl_stubs.a -o examples/actionslider_example_01.byte
File "_none_", line 1:
Error: Error on dynamically loaded library: ./src/dllefl_stubs.so: ./src/dllefl_stubs.so: undefined symbol: copy_Eina_List_Evas_Object
Command exited with code 2.
Compilation unsuccessful after building 1053 targets (899 cached) in 00:00:04.
Makefile:547 : la recette pour la cible « examples » a échouée

Here is the ouput of the make install that I tried even if the previous one failed.

make install
Installed /home/cedlemo/.opam/system/lib/efl/efl.a
Installed /home/cedlemo/.opam/system/lib/efl/libefl_stubs.a
Installed /home/cedlemo/.opam/system/lib/efl/efl.cmxs
Installed /home/cedlemo/.opam/system/lib/efl/efl.cmxa
Installed /home/cedlemo/.opam/system/lib/efl/efl.cmi
Installed /home/cedlemo/.opam/system/lib/efl/efl.cma
Installed /home/cedlemo/.opam/system/lib/efl/META
Installed /home/cedlemo/.opam/system/lib/stublibs/dllefl_stubs.so
Installed /home/cedlemo/.opam/system/lib/stublibs/dllefl_stubs.so.owner
ocamlfind: [WARNING] You have installed DLLs but the directory /home/cedlemo/.opam/system/lib/stublibs is not mentioned in ld.conf
../../install-sh: *.byte does not exist.
../../install-sh: *.native does not exist.
The examples have been installed as: /home/cedlemo/.opam/system/bin/ocaml-efl_***

How did you installed the EFL/Elementary ? By compiling the sources or by your package manager ?

Nothing fancy, I used the ArchLinux package manager.

FYI:

yaourt -Qi efl
Nom                      : efl
Version                  : 1.16.0-3
Description              : Enlightenment Foundation Libraries
Architecture             : x86_64
URL                      : http://www.enlightenment.org
Licences                 : BSD  LGPL2.1  GPL2  custom
Groupes                  : --
Fournit                  : --
Dépend de                : bullet  libjpeg-turbo  gst-plugins-base  luajit  curl  fribidi  libpulse  libxcomposite  libxinerama  libxrandr  libxss  libinput  libxcursor  libxp  libwebp
                           shared-mime-info  libxkbcommon  wayland  lz4  openjpeg  avahi
Dépendances opt.         : python2: einabench-cmp [installé]
Requis par               : elementary  emotion_generic_players  evas_generic_loaders
Optionnel pour           : --
Est en conflit avec      : --
Remplace                 : ecore  edje  eet  eeze  efreet  eina  eio  embryo  emotion  ethumb  evas
Taille installée         : 17,93 MiB
Paqueteur                : Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Compilé le               : sam. 26 déc. 2015 03:46:17 CET
Installé le              : sam. 02 janv. 2016 09:33:27 CET
Motif d’installation     : Explicitement installé
Script d’installation    : Oui
Validé par               : Signature

and

pkg-config --cflags efl
-I/usr/include/efl-1 -I/usr/include/eo-1 -I/usr/include/efl-1 -I/usr/include/eina-1 -I/usr/include/eina-1/eina

There is an opam package available for the EFL, but its a few months old. However, there has been a new release today, and the opam package should be available in a few days.

Ok, but sometimes I prefer to use the github version. It helps me to learn faster (the hard way you know) and sometimes I can give some feedback or help (well not for now with Ocaml).

This is a general remark about ocamlbuilld. Don't run ocamlbuild in a subdirectory of a directory where ocamlbuild has already been runed. If you want to test: 'ocamlbuild -use-ocamlfind -pkg efl something.byte' you should create a fresh directory (for example ~/test_ocaml_efl) and copy/write the .ml files in it.

Thanks for the informations, as a beginner with Ocaml, I find that the process to produce executable is not very obvious or clear at first sight. I will have to read more on it I guess.

cedlemo commented 8 years ago

I have uninstalled everything and installed the ocaml-efl 1.17 via opam. I have copied the examples in a new directory and tried to build one example:

ocamlbuild -use-ocamlfind -pkg efl bubble_example_01.byte
+ ocamlfind ocamlc -linkpkg -package efl bubble_example_01.cmo -o bubble_example_01.byte
File "_none_", line 1:
Error: Error on dynamically loaded library: /home/cedlemo/.opam/system/lib/stublibs/dllefl_stubs.so: /home/cedlemo/.opam/system/lib/stublibs/dllefl_stubs.so: undefined symbol: copy_Eina_List_Evas_Object
Command exited with code 2.
Hint: Recursive traversal of subdirectories was not enabled for this build,
  as the working directory does not look like an ocamlbuild project (no
  '_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
  you should add the option "-r" or create an empty '_tags' file.

  To enable recursive traversal for some subdirectories only, you can use the
  following '_tags' file:

      true: -traverse
      <dir1> or <dir2>: traverse

Compilation unsuccessful after building 3 targets (0 cached) in 00:00:00.
axiles commented 8 years ago

Could you give me the build log when your are trying to compile the first C example given here:

https://www.enlightenment.org/docs/efl/start

Just, to check you still gets all the warnings you posted.

cedlemo commented 8 years ago

No I have no warnings or errors, the two first examples can be built.

I will try to test in a clean install in a VM of ArchLInux in order to see if its my machine that have a specific configuration. I can make a vagrant file for you (using Virtualbox and an ArchLinux) if you are interested.

axiles commented 8 years ago

Have you previously runed the command:

eval $(opam config env)

which should be run every time you open a terminal (or you can put it in your ~/.bashrc) ?

cedlemo commented 8 years ago

I am using the fish shell but I have this in my configuration file:

set fisher_home ~/.config/fish/fisherman
set fisher_config ~/.config/fisherman
source $fisher_home/config.fish

set --erase fish_greeting
set -gx TERM "xterm-256color"
set -gx NVIM_LISTEN_ADDRESS "/tmp/nvim.sock"

# Load opam variables
source /home/cedlemo/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true

The last line does the same things :

init.fish

# Load the environment variables
source /home/cedlemo/.opam/opam-init/variables.fish > /dev/null 2> /dev/null; or true

variables.fish

# Current opam switch binary dir
set -gx PATH "/home/cedlemo/.opam/system/bin" $PATH;
if [ 0 -eq (count $MANPATH) ]; set -gx MANPATH ""; end;
# Current opam switch man dir
set -gx MANPATH $MANPATH "/home/cedlemo/.opam/system/man";
# Updated by compiler system
set -gx CAML_LD_LIBRARY_PATH "/home/cedlemo/.opam/system/lib/stublibs:/usr/lib/ocaml/stublibs";
cedlemo commented 8 years ago

So I tested in a newly created VM (virtualbox) and I had the same issue. If you wan to try : use vagrant and the archlinux box from https://github.com/terrywang/vagrantboxes/blob/master/archlinux-x86_64.md:

vagrant box add archlinux-x86_64 http://cloud.terry.im/vagrant/archlinux-x86_64.box
mkdir test_arch_64_ocaml_efl

In this directory add the following vargant file named "Vagrant"

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
  config.vm.box = "archlinux-x86_64"

   config.vm.provider "virtualbox" do |vb|
     # Display the VirtualBox GUI when booting the machine
     vb.gui = true

     # Customize the amount of memory on the VM:
     vb.memory = "1024"
   end
  shell_script =  <<-SHELL
  sudo pacman -Syu --noconfirm
  yaourt --noconfirm -S git opam efl elementary ocaml ocaml-findlib ocaml-ctypes unzip 
  opam init
  source /home/vagrant/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
  opam install efl
  git clone https://github.com/axiles/ocaml-efl
  cp -rf ocaml-efl/examples efl_examples
  cd efl_examples
  eval $(opam config env)
  ocamlbuild -use-ocamlfind -pkg efl bubble_example_01.byte
  SHELL
  config.vm.provision "shell", inline: shell_script, privileged: false
end

then do

cd test_arch_64_ocaml_efl
vagrant up --provision

It will take some times but at the end I have this message:

==> default: ocamlfind ocamldep -package efl -modules bubble_example_01.ml > bubble_example_01.ml.depends
==> default: ocamlfind ocamlc -c -package efl -o bubble_example_01.cmo bubble_example_01.ml
==> default: ocamlfind ocamlc -linkpkg -package efl bubble_example_01.cmo -o bubble_example_01.byte
==> default: + ocamlfind ocamlc -linkpkg -package efl bubble_example_01.cmo -o bubble_example_01.byte
==> default: File "_none_", line 1:
==> default: Error: Error on dynamically loaded library: /home/vagrant/.opam/system/lib/stublibs/dllefl_stubs.so: /home/vagrant/.opam/system/lib/stublibs/dllefl_stubs.so: undefined symbol: copy_Eina_List_Evas_Object
==> default: Command exited with code 2.
==> default: Hint: Recursive traversal of subdirectories was not enabled for this build,
==> default:   as the working directory does not look like an ocamlbuild project (no
==> default:   '_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
==> default:   you should add the option "-r" or create an empty '_tags' file.
==> default:   
==> default:   To enable recursive traversal for some subdirectories only, you can use the
==> default:   following '_tags' file:
==> default:   
==> default:       true: -traverse
==> default:       <dir1> or <dir2>: traverse
==> default:       

You can use vagrant ssh in order to investigate (I don't know is you have already used vagrant or not)

axiles commented 8 years ago

Thank you. I will investigate.

axiles commented 8 years ago

Ok, I think I solved the issue: it was about not having inline prototype functions. You can try to buil ocaml-efl with the last git version.

I remind you that for opam you have to do the configuration step as follows: ./configure --prefix=$(opam config var prefix) OCAMLFIND_DESTDIR=$(opam config var lib)

cedlemo commented 8 years ago

Ok, I think I solved the issue

Yes it works, everything is compiling.

Just to sumup (using bash):

./autoconf.sh
#for an installation in the opam dsubdirectories
./configure --prefix=$(opam config var prefix) OCAMLFIND_DESTDIR=$(opam config var lib)
make examples
make install

Thanks for your help. I will try to do the same with the fish shell and try your examples.