# Package frama-c not found after opam install

**URL:** <https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461>\
**Category:** Ecosystem\
**Tags:** opam, build, dune\
**Created:** [November 20, 2023, 7:50pm UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461 "2023-11-20T19:50:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discuss.ocaml.org/u/Mario)\
**Post date:** [November 20, 2023, 7:50pm UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461/1 "2023-11-20T19:50:33Z")

</div>

Hi,

I tried to install an old version of frama-c (because library cil requires ocaml \< 4.06) …

```auto
opam switch create 4.05-ocaml-cil 4.05.0+rc1
opam install frama-c

```

everything seems fine:

- `opam list | grep frama-c` provides `frama-c 21.1 Platform dedicated to ...`
- `$(opam var lib)/frama-c` provides `/home/***/.opam/4.05-ocaml-cil/lib/frama-c: Is a directory`
- `frama-c --version` is providing `21.1`

BUT `dune build` is complaining `Error: The package frama-c is not found` and `ocamlfind list` do not know or list the package.

I found similar topics, e.g. [https://discuss.ocaml.org/t/package-not-found-after-opam-install/11044](https://discuss.ocaml.org/t/package-not-found-after-opam-install/11044), but I wasn’t able to solve my issue.

I appreciate hints in all directions:

- How can I fix this gap between opan and ocmalfind?
- Why is it not possible to use the cil-library (I need cil\_types) with a current version of ocaml?
- Did I made something wired???

Thanks a lot in advance!!!

---

<div class="post-metadata">

**Author:** ![amaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amaro](https://discuss.ocaml.org/u/amaro)\
**Post date:** [November 21, 2023, 9:03am UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461/2 "2023-11-21T09:03:16Z")

</div>

Hello,

I’m not entirely sure what you are trying to do, but it seems something may have led you astray.

You mention that the `cil` library requires OCaml \< 4.06, which is nowadays a very old version. Indeed, as far as we know, the `cil` library is no longer maintained. But Frama-C includes its own (modified) version of CIL, which is completely independent from the `cil` package.

By the way, the version suffix `+rc1` means it is a _release candidate_, so older than the actual 4.05 version. In such cases, consider installing the “base” version, it will be more stable than a release candidate.

Now, **why** the cil project is no longer maintained, I don’t know. But if you want to use Frama-C’s version of `Cil_types`, just install a recent OCaml compiler, a recent Frama-C package, and configure a dune project to import Frama-C’s kernel. (I’ll try to provide a working example later.)

The last Frama-C version compatible with that old OCaml compiler (4.05) is indeed version 21. Frama-C did not use `dune` back then, so the available API was different. I’ll check about the other issues (dune build error and ocamlfind), but to answer your last 3 questions:

1. I’m not sure yet, I’ll check a few things related to it, but you probably won’t have the issue anyway, if you use a recent Frama-C. By the way, do not mix `opam` packages with `ocamlfind` packages; even if in many cases both exist with identical names, this is not always true.
2. Because cil library is no longer maintained, for several years now. But you can try using Frama-C’s Cil\_types instead.
3. Yes, you probably mixed up CIL and Frama-C’s CIL, and that is causing issues. Given that CIL is no longer a maintained package, I’m assuming you will be fine using Frama-C’s version of the library. So I’ll try providing some instructions about using its latest version.

In the meanwhile, if someone more savvy about ocamlfind could step in and explain the issue, that might help.

---

<div class="post-metadata">

**Author:** ![sim642](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sim642/32/3597_2.png) [@sim642](https://discuss.ocaml.org/u/sim642)\
**Post date:** [November 21, 2023, 9:33am UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461/3 "2023-11-21T09:33:29Z")

</div>

Not sure if it’s _only_ CIL you want, but the Goblint project still maintains a fork of standalone CIL: [GitHub - goblint/cil: C Intermediate Language](https://github.com/goblint/cil). It is also published on opam as goblint-cil.

If you want something to do with Frama-C, then goblint-cil won’t be relevant to you. Also, it has likely deviated significantly from Frama-C’s integrated version.

---

<div class="post-metadata">

**Author:** ![amaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amaro](https://discuss.ocaml.org/u/amaro)\
**Post date:** [November 21, 2023, 10:35am UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461/4 "2023-11-21T10:35:21Z")

</div>

Thanks for mentioning goblint-cil, I knew I had seen some recent version of cil somewhere but I couldn’t find it anymore, so I assumed I just misremembered it.

I just tried producing a minimal example of using the Frama-C kernel for Cil\_types, and frankly, it’s not as simple as I would like it to be.

Recent Frama-C versions have a `frama-c-build-scripts.sh` that should help, but it’s still cumbersome. Here’s how I produced a minimal example:

- Create a directory somewhere ( **not** inside a directory already containing a `dune-project` file, otherwise things will not work well! This also applies to parent folders, none of them may contain a `dune-project`, or you’ll have to manually set the `--root=DIR` option);
- inside it, create a subdirectory, for instance `foo`;
- run ` frama-c-build-scripts.sh init foo` (if you installed a recent Frama-C, this script should be in your PATH);
- put your code in a file such as `foo/script.ml` (`script.ml` can be named as you wish);
- run `dune build @install` to build it locally;
- run `dune exec -- frama-c -load-library frama-c-scripts.foo`. You should obtain the result of running your code.
- you can also run `dune install`, then you don’t need the `dune exec --` part. But this will install the “library” in your opam PATH. You can run `dune uninstall` to remove it.

Here’s the example code I tested:

```ocaml
open Frama_c_kernel

let () =
  match Cil.constFoldToInt
          (Cil.sizeOf ~loc:Cil_datatype.Location.unknown
             (Cil_types.TInt (Cil_types.IChar, [])))
  with
  | None -> Format.printf "constfold failed@."
  | Some sz -> Format.printf "sizeof(char) = %d@." (Integer.to_int_exn sz)

```

As expected, running `dune exec -- frama-c -load-library frama-c-scripts.foo` will output:

```
sizeof(char) = 1

```

But this is _way_ more complex than I would expect it. Unfortunately, the way Frama-C is currently developed, you cannot simply take the kernel and use it as a library; you actually need to create a _Frama-C library_ (almost the same as a Frama-C plug-in, in fact) and load it when running Frama-C itself.

So, if it is really only CIL that you need, using goblint-cil will probably be an easier approach.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discuss.ocaml.org/u/Mario)\
**Post date:** [November 23, 2023, 12:51pm UTC](https://discuss.ocaml.org/t/package-frama-c-not-found-after-opam-install/13461/5 "2023-11-23T12:51:00Z")

</div>

Thank you so much guys, you helped me a lot by providing such a detailled description.

I recognised, that cil (or cil\_types) is from 2013 and totally outdated, but I didn’t got that frama-c is using its own librarys, which seems to be highly extended.

I didn’t explained my goal in general, but the CIL-Module is pointing to c-analysis, so we decided to move closer to frama and I found my solution in the [plug-in-delevloper-guide of frama-c](https://www.frama-c.com/download/plugin-development-guide-27.1-Cobalt.pdf).

Thanks for the efforts and time you spend!
