Having an outside library and using it for a project

Hello,
I’m having trouble setting up my project.
Here is a the structure of my directory :

├─ lib
│  ├── lib1
│  │   ├── dune
│  │   ├── lib1.ml
│  │   └── lib1.mli
│  ├── lib2
│  │   ├── dune
│  │   └── lib2.ml
│  └── lib3
│      ├── dune
│      └── lib3.ml
├─ project
│  ├── dune_project
│  ├── bin
│      ├── dune
│      ├── main.ml
│      └── other.ml

First, I’d like to be able to open a library lib2 into another library i.e lib3.
Dune files of lib are like this

(library
	(name lib1))

And the dune file of my project is

(executable
 (name main)
 (libraries lib1 lib2 lib3))

But i get this error

Error: Library "lib3" not found.
Hint: try:
  dune external-lib-deps --missing @@default

What’s the maneuver to avoid copy pasting the whole library into the project folder?

If you want to access lib2 from within lib3 you need to add a (libraries lib2) to the stanza declaring lib3:

(library
 (name lib3)
 (libraries lib2))

Cheers,
Nicolas

2 Likes