# Using ocamlp-streams instead of Stdlib.streams

**URL:** <https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641>\
**Category:** Learning\
**Created:** [December 27, 2025, 9:13pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641 "2025-12-27T21:13:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratschan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ratschan/32/6334_2.png) [@ratschan](https://discuss.ocaml.org/u/ratschan)\
**Post date:** [December 27, 2025, 9:13pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/1 "2025-12-27T21:13:21Z")

</div>

Many years ago, I wrote a simple script using the Stdlib streams library. When trying to compile it nowadays, I get the message:

Alert deprecated: module Stdlib.Stream  
Use the camlp-streams library instead.

So I installed the camlp-streams library, and told ocamlc to use it:

ocamlc -I +camlp-streams camlp\_streams.cma x.ml

However, I still get the very same error message about Stdlib.streams being deprecated. So how do I teach ocamlc to use camlp\_streams and not Stdlib.streams?

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [December 27, 2025, 9:24pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/2 "2025-12-27T21:24:00Z")

</div>

Try something like:

```auto
ocamlfind ocamlc -g -linkpkg camlp-streams x.ml

```

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [December 28, 2025, 5:44am UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/3 "2025-12-28T05:44:54Z")

</div>

> [@ratschan](#):
>
> ocamlc -I +camlp-streams camlp\_streams.cma x.ml
> 
> However, I still get the very same error message about Stdlib.streams being deprecated.

If you installed `camlp-streams` using OPAM, it is not installed in the compiler directory but in the OPAM package directory, so the include directory to pass using `-I` is not `+camlp-streams` but one under your OPAM switch, eg:

```auto
ocamlc -I $(opam var camlp-streams:lib) camlp_streams.cma x.ml

```

> [@dbuenzli](#):
>
> Try something like:
> 
> ```auto
> ocamlfind ocamlc -g -linkpkg camlp-streams x.ml
> 
> ```

I think a `-package` flag is missing:

```auto
ocamlfind ocamlc -g -linkpkg -package camlp-streams x.ml

```

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![ratschan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ratschan/32/6334_2.png) [@ratschan](https://discuss.ocaml.org/u/ratschan)\
**Post date:** [December 28, 2025, 10:20am UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/4 "2025-12-28T10:20:07Z")

</div>

Thanks a lot for answering! The suggestion

ocamlfind ocamlc -g -linkpkg -package camlp-streams x.ml

seems to fit my setup, but the result is still the same (Alert deprecated: module Stdlib.Stream. Use the camlp-streams library instead)

I do not use opam, but the Ubuntu package libcamlp-streams-ocaml. Therefore the camlp\_streams library is in /usr/lib/ocaml/camlp-streams/camlp\_streams.cma

To sum up, I tried  
ocamlfind ocamlc -g -linkpkg -package camlp-streams x.ml  
ocamlc -I +camlp-streams camlp\_streams.cma x.ml  
ocamlc -I /usr/lib/ocaml/camlp-streams camlp\_streams.cma x.ml

and get the same error for all of them.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [December 28, 2025, 10:54am UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/5 "2025-12-28T10:54:04Z")

</div>

Can you perhaps show a minimal `x.ml` that exhibits the problem?

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [December 28, 2025, 11:21am UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/6 "2025-12-28T11:21:58Z")

</div>

Also the various exact versions of the compiler and library you are using. It seems work was done at some point for [“exporting without deprecation”](https://github.com/ocaml/camlp-streams/commit/9498a2c969c83a4df98dfdee8581b10f401e973c) perhaps you don’t have that commit.

---

<div class="post-metadata">

**Author:** ![ratschan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ratschan/32/6334_2.png) [@ratschan](https://discuss.ocaml.org/u/ratschan)\
**Post date:** [December 28, 2025, 2:07pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/7 "2025-12-28T14:07:15Z")

</div>

let main =  
let c= Stream.of\_channel stdin in  
0

already results in the error message.

ocamlc -v gives:

The OCaml compiler, version 4.14.1  
Standard library directory: /usr/lib/ocaml

on

Ubuntu 24.04.3 LTS

Package: libcamlp-streams-ocaml  
Version: 5.0.1-3build3

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [December 28, 2025, 2:26pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/8 "2025-12-28T14:26:48Z")

</div>

I can’t reproduce with OCaml 4.14.2 and opam’s `camlp-streams`:

```sh
> ocaml --version                                      
The OCaml toplevel, version 4.14.2
> opam info -f version camlp-streams
5.0.1
> cat x.ml                          
let () =
  let c = Stream.of_channel in
  ignore (c)
> ocamlfind ocamlc x.ml                                
File "x.ml", line 2, characters 10-27:
2 | let c = Stream.of_channel in
              ^^^^^^^^^^^^^^^^^
Alert deprecated: module Stdlib.Stream
Use the camlp-streams library instead.
> ocamlfind ocamlc -linkpkg -package camlp-streams x.ml
>

```

(My gut feeling would be that there is something wrong with the system camlp-streams install)

---

<div class="post-metadata">

**Author:** ![ratschan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ratschan/32/6334_2.png) [@ratschan](https://discuss.ocaml.org/u/ratschan)\
**Post date:** [December 28, 2025, 3:05pm UTC](https://discuss.ocaml.org/t/using-ocamlp-streams-instead-of-stdlib-streams/17641/9 "2025-12-28T15:05:49Z")

</div>

In the meanwhile, I tried to compile with ocamlopt, which works and solves my problem.

Thanks a lot for you help!
