Using ocamlp-streams instead of Stdlib.streams

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?

Try something like:

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

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:

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

I think a -package flag is missing:

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

Cheers,
Nicolas

1 Like

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.

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

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” perhaps you don’t have that commit.

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

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

> 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)

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

Thanks a lot for you help!

1 Like