Difficulties installing plplot in ocaml 5.2.1

I cannot install plplot due the dune build process failing, with seemingly an issue occurring due to a dropped const qualifier in the plplot c source.

  • Is there any way to coax the dune build to be more permissive with types?
  • Alternatively, what plotting libraries actually work with ocaml > 5.0?

opam switch: 5.2.1+options
dune: 3.17.2
fedora version: 41
plplot-devel: 5.15.0-72

dune build output:
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of plplot.5.12.0 failed at “dune build -p plplot -j 15”.

#=== ERROR while compiling plplot.5.12.0 ======================================#

context 2.3.0 | linux/x86_64 | ocaml-variants.5.2.1+options | pinned(file:///home/jacobw/Downloads/plplot-5.12.0)

path ~/.opam/5.2.1+options/.opam-switch/build/plplot.5.12.0

command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p plplot -j 15

exit-code 1

env-file ~/.opam/log/plplot-44177-3a679f.env

output-file ~/.opam/log/plplot-44177-3a679f.out

output

plplot_impl.c:351:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

[…]

plplot_impl.c: In function ‘ml_plparseopts’:

plplot_impl.c:704:41: error: passing argument 2 of ‘c_plparseopts’ from incompatible pointer type [-Wincompatible-pointer-types]

704 | result = plparseopts( &argv_length, c_argv, combined_parse_method );

| ^~~~~~

| |

| const char **

In file included from /usr/include/plplot/plplotP.h:151,

from plplot_impl.c:29:

/usr/include/plplot/plplot.h:2305:46: note: expected ‘PLCHAR_NC_MATRIX’ {aka ‘char **’} but argument is of type ‘const char **’

2305 | c_plparseopts( int *p_argc, PLCHAR_NC_MATRIX argv, PLINT mode );

| ~~~~~~~~~~~~~~~^~

Before going any further, are you able to install plplot with any other OCaml > 5.0 ? Does it install with OCaml 5.0.0 ?

Hello, I don’t know if this is useful or not, but:

(1) on Ubuntu 24.04
(2) dune 3.17.2
(3) OCaml 5.2.1 (a completely vanilla switch)

5.2.1 ocaml-base-compiler.5.2.1,ocaml-options-vanilla.1

(4) with plplot installed by Ubuntu:

ii libplplot-dev 5.15.0+dfsg2-9build1.1 amd64 Scientific plotting library (development files)

(5) I was able to cleanly with no complaints install it:

plplot 5.12.0 Bindings for the PLplot library

(6) When I THEN went to build the OCaml plplot library from source, I got the -same- warning you posted (but the build went thru fine):

plplot_impl.c: In function ‘ml_plparseopts’:
plplot_impl.c:704:41: warning: passing argument 2 of ‘c_plparseopts’ from incompatible pointer type [-Wincompatible-pointer-types]
  704 |     result = plparseopts( &argv_length, c_argv, combined_parse_method );
      |                                         ^~~~~~
      |                                         |
      |                                         const char **

(7) Also, here’s my gcc:

$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

To debug further, I might look at the dune “log” file, in “_build/log” and see what the “gcc” command that blew up was.

This is a C compiler warning you can ignore. I’m guessing it’s caused by ctypes and I don’t think it’s worth the effort to fix it if it would make ctypes more complicated. (const here leads to a warning rather than an error, the datatype is correct.)

Thanks for replying!

the provided error warning was given when the ‘opam install plplot’ command failed. I did try later to manually build the plplot-ocaml github repository, but received the same warning.

I have since tested the opam install plplot command with switches ( 4.08.1, 5.0.0, 5.3.1+options) to the same effect,

looking at the _build/log for the local repository
the build command/s for the external library where
$ /home/jacobw/.opam/4.14.2/bin/ocamlc.opt -config > /tmp/dune_c97c72_output
$ (cd _build/default/src && /usr/lib64/ccache/gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -g -O2 -I/usr/include/plplot -g -I /home/jacobw/.opam/4.14.2/lib/ocaml -o idlalloc.o -c idlalloc.c)
$ (cd _build/default/src && /usr/lib64/ccache/gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -g -O2 -I/usr/include/plplot -g -I /home/jacobw/.opam/4.14.2/lib/ocaml -o plplot_impl.o -c plplot_impl.c)

I’ve tried changing the flag configurations within the src/dune file : removing :standard , and adding -w. to no particular effect.

dune seems to still be using the flags given to it by ocamlc.opt -options (which includes -fno-strict-aliasing) for the gcc command, and I am not certain how to prevent dune from passing them in.

I looked in the _build/log for my 5.2.1 switch, compiling plplot.5.12.0 (as before) and found:

$ (cd _build/default/src && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -pthread -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -pthread -g -O2 -I/usr/include/plplot -g -I /home/chet/Hack/Opam-2.3.0/GENERIC/5.2.1/lib/ocaml -o plplot_impl.o -c plplot_impl.c)

Squinting, that looks pretty much like your gcc invocation, doesn’t it? I don’t see the difference.

So I thought: why don’t I run the command? And yeah, the command goes thru without any trouble. Could I suggest that you do the same? That is, take the command from your build/log and run it in a shell?

And also, what’s the output of “gcc --version” on your machine?

Last: can you turn off this “ccache” stuff? Is that perhaps related to your problem?

Since GCC 14, passing pointers with incompatible types is no longer just a warning, it is a hard error. You need to pass the option -Wno-error=incompatible-pointer-types to revert to the old behavior of GCC.

I was able to build plplot successfully by adding both
-w and -Wno-error=incompatible-pointer-types
to the src/dune flags list
neither of the flags individually resolved the build failure.

Thank you for the help and time

Probably worth opening an issue with the plplot package, so they fix it there also.