3

My system is 3.11.0-24-generic #41-Ubuntu SMP Mon Jun 9 20:36:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

I successfully installed camlimages.

Then I took the example:

let () =
  let img = Rgb24.create 1 1 in
  Rgb24.set img 0 0 { Color.r = 255; g = 0; b = 0 };
  Jpeg.save "sample.jpg" [] (Images.Rgb24 img)

Then I used

ocamlbuild -use-ocamlfind -package camlimages -package camlimages.jpeg test.native

to compile and it was successful as well.

finally, when I tried to run ./test.native, it says

Fatal error: exception Failure("unsupported")

Why? How to fix?

By the way, after I used opam install, it didn't give any error but if I try to -package camlimages.all, then it says I don't have camlimages.freetype, why?


I did ocamlfind list | grep camlimages, it shows:

camlimages          (version: 4.1.1)
camlimages.all      (version: 4.1.1)
camlimages.all_formats (version: 4.1.1)
camlimages.core     (version: 4.1.1)
camlimages.exif     (version: 4.1.1)
camlimages.gif      (version: 4.1.1)
camlimages.graphics (version: 4.1.1)
camlimages.jpeg     (version: 4.1.1)
camlimages.png      (version: 4.1.1)
camlimages.ps       (version: 4.1.1)
camlimages.tiff     (version: 4.1.1)
camlimages.xpm      (version: 4.1.1)

After turn on the debug, now it shows

Raised by primitive operation at file "jpeg.ml", line 152, characters 6-308
Called from file "test.ml", line 5, characters 2-46
9
  • compile with bytecode and add "OCAMLRUNPARAM='b'" to your environment to see where that very unhelpful message is coming from.
    – nlucaroni
    Jul 17, 2014 at 15:08
  • Could you verify that this (from my comment) works?, stackoverflow.com/questions/612886/…
    – nlucaroni
    Jul 17, 2014 at 15:09
  • @nlucaroni I tried ocamlbuild -use-ocamlfind -package camlimages -package camlimages.jpeg -cflag -g test.byte and when run with OCAMLRUNPARAM=b, it says (Cannot print stack backtrace: program not linked with -g) Jul 17, 2014 at 15:50
  • @nlucaroni Could you verify that this (from my comment) works?, stackoverflow.com/questions/612886/… what do you mean? Jul 17, 2014 at 15:51
  • @nlucaroni you mean I check the package name? I use opam to install it and opam listed camlimages package Jul 17, 2014 at 15:56

1 Answer 1

3

camlimages has a number of different file-types it supports, all optionally. You'll have to install them before you install camlimages from opam. From the ubuntu repositories you can install the following,

libpng12-dev libjpeg-dev libtiff-dev libxpm-dev libfreetype6-dev libgif-dev

OPAM has a new depext field but I guess it hasn't been updated for camlimages --or maybe not appropriate since these are optional packages. You can see an example of this on the gsl opam files.

3
  • after I apt-get those libs, problems are gone, thanks to nlucaroni and the author of camlimages Jul 18, 2014 at 9:47
  • What needs to be installed on OSX? Jan 10, 2017 at 9:20
  • 1
    For OSX, these packages can be installed via homebrew... brew install libpng libjpeg libtiff
    – nlucaroni
    Jan 10, 2017 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.