kandu / ocaml-fswatch

4 stars 3 forks source link

cannot install on linux #2

Open sanette opened 1 year ago

sanette commented 1 year ago

it seems that the option -lfswatch should be removed

$ opam install fswatch
The following actions will be performed:
  ∗ install conf-fswatch 11-0.1.0 [required by fswatch]
  ∗ install fswatch      11-0.1.1
===== ∗ 2 =====
Do you want to continue? [Y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing  2/6:
⬇ retrieved fswatch.11-0.1.1  (cached)
[ERROR] The compilation of conf-fswatch.11-0.1.0 failed at "sh -exec cc
        -I/usr/local/include/libfswatch/c -I/usr/include/libfswatch/c $CFLAGS test.c -lfswatch".

#=== ERROR while compiling conf-fswatch.11-0.1.0 ==============================#
# context     2.1.2 | linux/x86_64 | ocaml-base-compiler.5.0.0 | https://opam.ocaml.org#a937a5ea
# path        ~/.opam/5.0.0/.opam-switch/build/conf-fswatch.11-0.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build sh -exec cc -I/usr/local/include/libfswatch/c -I/usr/include/libfswatch/c $CFLAGS test.c -lfswatch
# exit-code   1
# env-file    ~/.opam/log/conf-fswatch-31334-3625bf.env
# output-file ~/.opam/log/conf-fswatch-31334-3625bf.out
### output ###
# + cc -I/usr/local/include/libfswatch/c -I/usr/include/libfswatch/c test.c -lfswatch
# /usr/bin/ld : ne peut pas trouver -lfswatch : Aucun fichier ou dossier de ce type
# collect2: error: ld returned 1 exit status
kandu commented 1 year ago

It's a known issue, https://github.com/ocaml/opam-repository/issues/22256

sanette commented 1 year ago

I see, but can you adapt to the debian package, instead of waiting for (hypothetical) changes? Then I could use your library ;)

kandu commented 1 year ago

Haha, I can't adapt something that doesn't exist, the missing dev package.

But we can complement the broken debian package on our own.

  1. Suppose we are in a debian x86-64 system: add a file named fswatch.conf to /etc/ld.so.conf.d . and the content of it is /usr/lib/x86_64-linux-gnu/libfswatch then invoke ldconfig
  2. LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/libfswatch opam install fswatch_async fswatch_lwt

The path of the library is system/config specialized, there are so many different distributions / architectures, we can't break all the compatibilities for only one architecture of only one distribution.

sanette commented 1 year ago

In the opam file you can add rules depending on the distribution, maybe you could try this? I understand it's complicated, I'm not saying it's easy. I'm just wondering, since debian is quite popular, it could be worth it.

kandu commented 1 year ago

Thanks for your suggestions. i.e. {os-family = "debian"} conditional statement in an opam file.

Even if we add rules to the opam file and add necessary tweaks to the build command, the dynamic library still doesn't work, so the built fswatch and executables depending on it still will not work.

This is what we'll see: error while loading shared libraries: libfswatch.so.11: cannot open shared object file: No such file or directory

Since debian is quite popular, it's odd that debian published such a low-quality package :( Any better ideas?

sanette commented 1 year ago

I had similar problems with tsdl-image (and likes) in MacOS, the libraries could not be found. We were able to add a specific case for MacOS. However we were using ctypes, so I'm afraid I cannot tell you to do the same :(