Skip to content

Linking C libraries for inline test runners #1530

@psteckler

Description

@psteckler

I have an OCaml library that gets built by dune, which calls code in a Linux dynamic library (using the Ctype.Foreign mechanism). I have other OCaml code that calls this OCaml library, from which dune builds an executable. That executable shows errors when it's run, unless I add flags to the dune file so that the OCaml compiler links against the Linux library (it's librocksdb.so).

The library also contains inline tests, and I see the same kind of error when the inline test runner executes. The solution should be to link against the same Linux library when the inline test runner, run.exe, is built. I don't see how to do that from the dune file.

Do I need to modify dune to do that linking?

Also, there is an example in the dune documentation about adding (OCaml) libraries which suggests I could write a clause like this:

(inline_tests (libraries some_lib))

For me, dune 1.4 rejects this syntax. Instead, it accepts:

(inline_tests ((libraries (some_lib))))

This mechanism doesn't have to do with the issue described above, just that I tried the syntax when fiddling with the dune file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueGood for contributing for the first time to the Dune codebase

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions