No, actually it changes the error message but ocaml still complain dream is not linked
the error is now
Error: No implementations provided for the following modules:
Digestif referenced from /home/frederic/.opam/4.13.1/lib/dream/http/dream__http.cmxa(Dream__http__Http)
while digestif is installed and the compile command is updated to
ocamlfind ocamlopt -thread -linkpkg -package dream,digestif test.ml -o test
Hi, is there any strong reason why you are not using dune? Dream works very well with dune especially because dune’s watch mode can automatically recompile and restart your server on code change. And Dream’s livereload feature will also automatically force a page reload. It’s a very productive workflow.
Yes, I have to include some library store in my local file system that are not compile with dune. I use the -I ../../lib flag with ocamlfind to include such dependency. As far as I know dune is not good to include custom dependency ‘<>.cmxa’ so I fall back to the standard ocamlfind build process
Unfortunately this turned out to be more difficult than I thought. I made some progress but got stuck on a dead end. Maybe someone smarter than me can figure out how to make it work. Here are my steps in case anyone wants to reproduce (I am assuming a standard setup with an opam switch and dune):
# Set up project
mkdir cmxproj
cd cmxproj
echo '(lang dune 3.6)' >dune-project
mkdir cmxpkg bin
# Set up a fake cmx-only 'library' for testing
cd cmxpkg
echo 'let x = 1' >cmxpkg.ml
ocamlopt -c cmxpkg.ml -o cmxpkg.o
cat <<EOF >META
version = "0.0.1"
description = ""
archive(native) = "cmxpkg.cmxa"
EOF
# Create the archive files
ocamlopt -a cmxpkg.cmx cmxpkg.o -o cmxpkg.cmxa cmxpkg.a
# Install the fake 'library' in the switch
ocamlfind install cmxpkg META cmxpkg.a cmxpkg.cmi cmxpkg.cmx cmxpkg.cmxa cmxpkg.a
# Use the fake library
cd ../bin
echo '(executable (name bin) (libraries cmxpkg))' >dune
echo 'let () = print_int Cmxpkg.x' >bin.ml
# Build
cd ..
dune build
Here’s the error I get:
File "bin/dune", line 2, characters 7-10:
2 | (name bin)
^^^
clang: error: no such file or directory: 'cmx.o'
clang: error: no such file or directory: 'cmx.a'
File "caml_startup", line 1:
Error: Error during linking (exit code 1)
Which I can’t figure out because both of the mentioned files are installed in the cmxpkg package directory by ocamlfind. And Google is not particularly helpful here because it looks like approximately no one is doing this