Giter VIP home page Giter VIP logo

graphics's Introduction

⚠️ CAUTION

The developer team released OCaml 5.0.0 in December 2022. This release sports a full rewrite of its runtime system for shared-memory parallel programming using domains and native support for concurrent programming using effect handlers.

Owing to the large number of changes, the initial 5.0 release is more experimental than usual. It is recommended that all users wanting a stable release use the 4.14 release which will continue to be supported and updated while 5.x reaches feature and stability parity. Similarly, if you need one of the ports not yet supported in the 5.0 release you must use the 4.14 release.

The initial release of OCaml 5.0 only supports the native compiler under ARM64 and x86-64 architectures under Linux, macOS and the BSDs. On Windows, only the MinGW-w64 port is supported in OCaml 5.0 and the Cygwin port is restored in 5.1. On Linux, native code support for RISC-V and s390x/IBM Z is available in OCaml 5.1 and in 5.2 for Power.

❗ From OCaml 5.0 onwards, native compilation is available only on 64-bit systems. Native compilation on 32-bit systems is no longer available, nor are there plans to bring it back. The bytecode compiler will continue to work on all architectures.

Branch trunk Branch 5.2 Branch 5.1 Branch 5.0 Branch 4.14

Github CI Build Status (trunk branch) Github CI Hygiene Status (trunk branch) AppVeyor Build Status (trunk branch)

Github CI Build Status (5.2 branch) AppVeyor Build Status (5.2 branch)

Github CI Build Status (5.1 branch) AppVeyor Build Status (5.1 branch)

Github CI Build Status (5.0 branch) AppVeyor Build Status (5.0 branch)

Github CI Build Status (4.14 branch) AppVeyor Build Status (4.14 branch)

README

Overview

OCaml is a functional, statically-typed programming language from the ML family, offering a powerful module system extending that of Standard ML and a feature-rich, class-based object system.

OCaml comprises two compilers. One generates bytecode which is then interpreted by a C program. This compiler runs quickly, generates compact code with moderate memory requirements, and is portable to many 32 or 64 bit platforms. Performance of generated programs is quite good for a bytecoded implementation. This compiler can be used either as a standalone, batch-oriented compiler that produces standalone programs, or as an interactive REPL system.

The other compiler generates high-performance native code for a number of processors. Compilation takes longer and generates bigger code, but the generated programs deliver excellent performance, while retaining the moderate memory requirements of the bytecode compiler. The native-code compiler currently runs on the following platforms:

Tier 1 (actively maintained) Tier 2 (maintained when possible)

x86 64 bits

Linux, macOS, Windows, FreeBSD

NetBSD, OpenBSD, OmniOS (Solaris)

ARM 64 bits

Linux, macOS

FreeBSD, OpenBSD, NetBSD

Power 64 bits

Linux (little-endian, ABIv2)

Linux (big-endian, ABIv2)

RISC-V 64 bits

Linux

IBM Z (s390x)

Linux

Other operating systems for the processors above have not been tested, but the compiler may work under other operating systems with little work.

All files marked "Copyright INRIA" in this distribution are Copyright © 1996-2023 Institut National de Recherche en Informatique et en Automatique (INRIA) and distributed under the conditions stated in file LICENSE.

Installation

See the file INSTALL.adoc for installation instructions on machines running Unix, Linux, macOS, WSL and Cygwin. For native Microsoft Windows, see README.win32.adoc.

Documentation

The OCaml manual is distributed in HTML, PDF, and Emacs Info files. It is available at

Availability

The complete OCaml distribution can be accessed at

Keeping in Touch with the Caml Community

There is an active and friendly discussion forum at

The OCaml mailing list is the longest-running forum for OCaml users. You can email it at

You can subscribe and access list archives via the Web interface at

There also exist other mailing lists, chat channels, and various other forums around the internet for getting in touch with the OCaml and ML family language community. These can be accessed at

In particular, the IRC channel #ocaml on Libera has a long history and welcomes questions.

Bug Reports and User Feedback

Please report bugs using the issue tracker at https://github.com/ocaml/ocaml/issues

To be effective, bug reports should include a complete program (preferably small) that exhibits the unexpected behavior, and the configuration you are using (machine type, etc).

For information on contributing to OCaml, see HACKING.adoc and CONTRIBUTING.md.

Separately maintained components

Some libraries and tools which used to be part of the OCaml distribution are now maintained separately and distributed as OPAM packages. Please use the issue trackers at their respective new homes:

Library Removed since OPAM package

The Stream and Genlex standard library modules

OCaml 5.0

camlp-streams

The Graphics library

OCaml 4.09

graphics

The Num library

OCaml 4.06

num

The OCamlbuild tool

OCaml 4.03

ocamlbuild

The camlp4 tool

OCaml 4.02

camlp4

The LablTk library

OCaml 4.02

labltk

The CamlDBM library

OCaml 4.00

dbm

The OCamlWinTop Windows toplevel

OCaml 4.00

none

graphics's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphics's Issues

Cannot build graphics 5.0.1 on Linux

I was trying to build ocaml-graphics for my system using the AUR package. What it does is downloading the source package, extract it, and run dune build -p graphics in it. It fails with the following error message:

    ocamlopt src/discover/discover.exe (exit 2)
(cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -o src/discover/discover.exe /usr/lib/ocaml/unix.cmxa -I /usr/lib/ocaml /usr/lib/ocaml/dune-configurator/configurator.cmxa src/discover/.discover.eobjs/native/discover.cmx)
File "_none_", line 1:
Error: Files /usr/lib/ocaml/dune-configurator/configurator.cmxa
       and /usr/lib/ocaml/stdlib.cmxa
       make inconsistent assumptions over implementation Stdlib__sys
Done: 81/107 (jobs: 1)

Compiling the 5.0.0 sources yields no error.

Make Graphics module use modern X fonts instead of X core fonts

(The following issue was imported from the OCaml bugtracker)

Original bug ID: 4917
Reporter: Richard Jones
Status: acknowledged (set by @damiendoligez on 2009-12-08T16:33:11Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.11.1
Category: otherlibs
Tags: patch
Monitored by: mehdi @glondu @hcarty @Chris00

Bug description

X core fonts have been deprecated for many years. Fedora are trying to identify pieces of software which still use X core fonts and could be changed to use modern X fonts (based on Xft and FontConfig). The OCaml Graphics module is one such place.

The attached patch changes the Graphics module to use modern X fonts. The changes are relatively simple - changing calls such as XDrawString to use the Xft equivalent (XftDrawString8).

One immediate advantage is that Graphics users will see anti-aliased fonts.

Another advantage is that Graphics users can specify font names like "Times-12" instead of the massive and incomprehensible XLFD strings ("--times--r-....")

File attachments

Question: how to handle close of window?

I'm on macos

I opened a window from ocaml shell, the XQuartz window opens. If I then close the window from the 'x' button on the window controls I get this error and the ocaml shell crashes:

# Fatal error: exception Graphics.Graphic_failure("fatal I/O error")

(closing from code Graphics.close_graph ();; works fine)

Is there a way to handle the close button so it doesn't cause an error?

Rectangle madness

Original bug ID: 7498
Reporter: iesvs
Assigned to: @diml
Status: assigned (set by @diml on 2017-04-21T12:43:38Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.04.0
Category: standard library

Bug description

Graphics.draw_rect and Graphics.fill_rect have strange behaviors.

I will suppose that they use the same meaning for their arguments.
I see two behaviors

  1. how I understand the documentation
    fill_rect x y z h
    means { px, py : x <= px < x + w and y <= py < y + h }

  2. what is currently implemented on Linux
    fill_rect x y z h
    means { px, py : x <= px <= x + w and y <= py <= y + h }

In any cases the behavior of windows must be the same. I use the C compiler of VS 2010 to compile ocaml.

For the case 1, Linux must be changed and Windows too
I have the fix fix1.patch

For the case 2, Windows does not do the same thing as Linux
I have the fix fix2.patch

I also add a test file (test.ml).

ocamlopt -o test graphics.cmxa test.ml && ./test 1
will test the case 1
and
ocamlopt -o test graphics.cmxa test.ml && ./test 2
will test the case 2

The documentation of get_image states that the arguments have the same meaning than fill_rect. That's why case 1 is probably the expected behavior.

By the way, there is the commit
9f20c9c8a10307f40406890352ba3fbb2e4bd735
which looks like the opposite of fix1 (for the Linux part). That's strange.

I don't have Mac OS X to test, sorry.

File attachments

set_text_size doesn't work

Original bug ID: 4677
Reporter: Outsider
Status: confirmed (set by @damiendoligez on 2012-09-17T11:37:50Z)
Resolution: open
Priority: normal
Severity: text
Version: 3.11.0+beta
Target version: later
Category: standard library
Monitored by: Outsider

Bug description

It is like I said : it doesn't work and it bothers me.
I have to create a little game and I hoped to changed things the way I liked.
It is not a major problem but it could be better to fix this problem.

Graphics: foreground and background colors should be changeable

Original bug ID: 1710
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

tags 179254 upstream
severity wishlist
thanks

Bonjour,

Je suis en train de faire le menage dans le bts du package debian ocaml,
et je suis tomber sur ces deux bugreports, que je pensais avoir fait
suivre upstram precedement, mais que je ne retrouve pas dans le BTS
ocaml. Voila qui est fait donc.

Amicalement,

Sven Luther

On Fri, Jan 31, 2003 at 09:34:11PM +0100, Goswin Brederlow wrote:

Package: ocaml
Version: 3.06-15
Severity: wishlist

There seems to be no way to change the foreground and background
colors in module Graphics. The problem is that X uses the background
color to fill in missing peaces when resizeing or when uncovering
regions before seding an expose event. If the background is white and
the actual graphic displayed is black that is very anoying to the eye.

Setting the background color to something roughly reflecting the
average color displayed greatly reduces flickering.

MfG
Goswin

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux dual 2.4.19 #11 SMP Thu Jan 9 00:18:31 CET 2003 i686
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages ocaml depends on:
ii libc6 2.3.1-10 GNU C Library: Shared libraries an
ii libncurses5-dev 5.3.20021109-2 Developer's libraries and docs for
ii ocaml-base [ocaml-base-3. 3.06-15 Runtime system for ocaml bytecode

-- debconf information excluded

Cannot install graphics in ubuntu 20.04 on Windows laptop

I have been trying to install graphics using "opam install graphics" in ubuntu. But I kept running into this error:

[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

The following actions will be performed:
  ∗ install   conf-libX11       1      [required by graphics]
  ∗ install   graphics          5.1.2
  ↻ recompile ocamlfind         1.9.1  [uses graphics]
  ↻ recompile dot-merlin-reader 4.1    [uses ocamlfind]
  ↻ recompile base-bytes        base   [uses ocamlfind]
  ↻ recompile ocaml-lsp-server  1.8.2  [uses dot-merlin-reader]
  ↻ recompile zed               3.1.0  [uses base-bytes]
  ↻ recompile qcheck-core       0.18   [uses base-bytes]
  ↻ recompile ounit2            2.2.4  [uses base-bytes]
  ↻ recompile ocplib-endian     1.1    [uses base-bytes]
  ↻ recompile ocp-indent        1.8.1  [uses ocamlfind]
  ↻ recompile ANSITerminal      0.8.2  [uses base-bytes]
  ↻ recompile qcheck-ounit      0.18   [uses base-bytes]
  ↻ recompile lwt               5.4.2  [uses ocplib-endian]
  ↻ recompile ocamlformat-rpc   0.19.0 [uses ocp-indent]
  ↻ recompile ocamlformat       0.19.0 [uses ocp-indent]
  ↻ recompile qcheck            0.18   [uses base-bytes]
  ↻ recompile lwt_react         1.1.4  [uses lwt]
  ↻ recompile lwt_log           1.1.1  [uses lwt]
  ↻ recompile lambda-term       3.1.0  [uses zed]
  ↻ recompile utop              2.8.0  [uses ocamlfind]
===== ∗ 2   ↻ 19 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ANSITerminal.0.8.2] found in cache
[dot-merlin-reader.4.1] found in cache
[graphics.5.1.2] found in cache
[lambda-term.3.1.0] found in cache
[lwt.5.4.2] found in cache
[lwt_log.1.1.1] found in cache
[lwt_react.1.1.4] found in cache
[ocaml-lsp-server.1.8.2] found in cache
[ocamlfind.1.9.1] found in cache
[ocamlformat.0.19.0] found in cache
[ocamlformat-rpc.0.19.0] found in cache
[ocp-indent.1.8.1] found in cache
[ocplib-endian.1.1] found in cache
[ounit2.2.2.4] found in cache
[qcheck.0.18] found in cache
[qcheck-core.0.18] found in cache
[qcheck-ounit.0.18] found in cache
[utop.2.8.0] found in cache
[zed.3.1.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of conf-libX11 failed at "/home/danju666/.opam/opam-init/hooks/sandbox.sh build pkg-config
        x11".

#=== ERROR while compiling conf-libX11.1 ======================================#
# context     2.0.5 | linux/x86_64 | ocaml-base-compiler.4.12.0 | https://opam.ocaml.org#ef82e5bc
# path        ~/.opam/cs3110-2021fa/.opam-switch/build/conf-libX11.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build pkg-config x11
# exit-code   1
# env-file    ~/.opam/log/conf-libX11-42-626d32.env
# output-file ~/.opam/log/conf-libX11-42-626d32.out
### output ###
# bwrap: execvp pkg-config: No such file or directory
# bwrap: execvp pkg-config: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build conf-libX11 1
└─
╶─ No changes have been performed

The packages you requested declare the following system dependencies. Please make sure they are installed before
retrying:
    libx11-dev

Unable to install on Mac OS 10.14.6

Hi,

I'm unable to install the package on MacOS 10.14 (Mojave), while it did work when graphics was bundled with ocaml.

Here is the error:

src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>

I have xquartz installed.

Doing a

sudo ln -s /opt/X11/include/X11 /usr/local/include/X11

(as mentioned here) just changes the error to:

ld: library not found for -lX11
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea?

Thanks

4.10 dune runtest fails undefined reference to caml_process_pending_signals

With commit ocaml/ocaml@fc788ef I get this error with dune runtest:

[   54s] Command [6] exited with code 2:
[   54s] $ (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -o test/test.exe -I src src/graphics.cmxa test/.test.eobjs/native/test.cmx)
[   54s] /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src/libgraphics_stubs.a(events.o): in function `caml_gr_wait_event_poll':
[   54s] /home/abuild/rpmbuild/BUILD/ocaml-graphics-5.0.0/_build/default/src/src/unix/events.c:166: undefined reference to `caml_process_pending_signals'
[   54s] collect2: error: ld returned 1 exit status
[   54s] File "caml_startup", line 1:
[   54s] Error: Error during linking

Not sure if this is an issue in ocaml to be resolved, or if external packages need to be tweaked to support 4.10.

Compilation on native Windows fails

Logs

Steps to reproduce and logs :
https://github.com/GauBen/bcotp/runs/1599361734?check_suite_focus=true#step:5:68

# C:/cygwin/home/runneradmin/.opam/ocaml-variants.4.11.1+mingw64c/lib/ocaml/caml/mlvalues.h:265:24: warning: passing argument 1 of 'gr_font' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
#   265 | #define String_val(x) ((const char *) Bp_val(x))
#       |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
# src/win32/draw.c:340:17: note: in expansion of macro 'String_val'
# src/win32/draw.c:325:27: note: expected 'char *' but argument is of type 'const char *'
#   ocamlmklib src/dllgraphics_stubs.dll,src/libgraphics_stubs.a (exit 2)
# (cd _build/default && C:\cygwin\home\runneradmin\.opam\ocaml-variants.4.11.1+mingw64c\bin\ocamlmklib.opt.exe -g -o src/graphics_stubs src/draw.o src/events.o src/open.o -lkernel32 -lgdi32 -luser32)
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x5c): multiple definition of `grremember_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x60): first defined here
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x60): multiple definition of `grdisplay_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x64): first defined here
# collect2: error: ld returned 1 exit status
# ** Fatal error: Error during linking

Or:

  • Install Cygwin
  • Install Opam and OCaml 4.11.1
  • opam install graphics

Solution

I found a way to compile graphics on Cygwin:

  • Remove or comment lines 26 and 27 in src/win32/draw.c
  • Remove "conf-libX11" in dune-project and graphics.opam

Regards,
Gautier

Cannot load graphics library on ARM macOS

Hey!

I've been trying to play with OCaml on ARM-based macOS, but I've been facing an issue which can be problematic for my usage.
Everything works fine, except for the graphics library which completely refuse to load up.
OCaml runs on version 4.12.0 freshly installed from opam, packages �core and graphics were added too to bring up graphics functionnality.

I use OCaml's top find in order to get my libraries loaded, here is a sample code:

#use "topfind";;
#require "graphics";;

While this code works on my native Linux (Debian) system, and my Debian on Windows 10 through WSL2... it does not work here.

# #require "Graphics";;
/Users/kevin/.opam/default/lib/Graphics: added to search path
/Users/kevin/.opam/default/lib/Graphics/graphics.cma: loaded
Cannot load required shared library dllgraphics_stubs.
Reason: /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so: dlopen(/Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so, 10): Symbol not found: _XAllocColor
  Referenced from: /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so
  Expected in: flat namespace
 in /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so.

I do get this weird error, apparently a library isn't providing what it should which leads OCaml to fail up loading it... but I can't find anything related when searching on Google.
Side note, I haven't got any error or warning then opam was installing OCaml, core and graphics packages - aside from the classic pkg-config I had to install on all my systems anyway.

I'm using a late-2020 MacBook Air with an M1 chip, on macOS Big Sur 11.2.2.
I'm up to you if you need any more information or debug files.

Thanks!

License exception may need an update

The linkage exception in the LICENSE file refers to "OCaml Core System", which I presume originates from a time when the graphics library was distributed with the OCaml compiler.

Re: ocaml: module Graphics: type event should include a resize event

(The following issue was imported from the OCaml bugtracker)

Original bug ID: 1711
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

tags 179255 upstream
severity 179255 whishlist
thanks

Bonjour,

Je suis en train de faire le menage dans le bts du package debian ocaml,
et je suis tomber sur ces deux bugreports, que je pensais avoir fait
suivre upstram precedement, mais que je ne retrouve pas dans le BTS
ocaml. Voila qui est fait donc.

Amicalement,

Sven Luther

On Fri, Jan 31, 2003 at 09:38:12PM +0100, Goswin Brederlow wrote:

Package: ocaml
Version: 3.06-15
Severity: wishlist

It would be nice if one could also wait for a resize event (and maybe
even expose events to trigger redraws when not using double buffering).

MfG
Goswin

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux dual 2.4.19 #11 SMP Thu Jan 9 00:18:31 CET 2003 i686
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages ocaml depends on:
ii libc6 2.3.1-10 GNU C Library: Shared libraries an
ii libncurses5-dev 5.3.20021109-2 Developer's libraries and docs for
ii ocaml-base [ocaml-base-3. 3.06-15 Runtime system for ocaml bytecode

-- debconf information excluded

Graphics broken pipe

Original bug ID: 3668
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

Full_Name: e. amian
Version: Objective Caml version 3.08.3
OS: Linux 2.6.11-gentoo-r8
Submission from: hoproxy.proxy.lucent.com (192.11.226.116)

Closing a Graphics window by clicking on top right 'close button'
(delete_event)
crashes the top level. Sample session
Objective Caml version 3.08.3

Graphics.open_graph " 200x200";;

  • : unit = ()

Broken pipe

Multiple mouse buttons for Graphics

Original bug ID: 3693
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs
Monitored by: @Chris00

Bug description

Full_Name: Ken Rose
Version: 3/08.1
OS: Linux
Submission from: o1-dialup-66-81-19-51.rev.o1.com (66.81.19.51)

It would be very useful if the graphics library distinguished among the various
mouse buttons, rather than forcing them all together, as in the current
implementation.

I'd be willing to implement the change and submit a patch, if that's desireable.
A quick look suggests it might be pretty easy to do, though I'm not certain
there is no trap lurking.

Thanks

  • ken

Graphics background color under Windows

Original bug ID: 7745
Reporter: sampo
Status: confirmed (set by @dra27 on 2018-02-23T21:39:34Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.0
Category: otherlibs
Monitored by: @nojb

Bug description

Hello everybody.
I tested this program found at this address https://www.typerex.org/images/ocpwin-graphics.png

#load "graphics.cma";;

open Graphics;;

open_graph "600x600";;

  • : unit = ()

draw_poly [| 30,300; 200,40; 400,190; 250,500 |];;

  • : unit = ()

set_color red;;

  • : unit = ()

fill_poly [| 35,300; 200,45; 395,190; 250,495 |];;

  • : unit = ()
    With Windows(OCaml 4.06.0), two things are different:
  1. instead of writing on the graphic window "OCaml graphics" it is
    written Chinese characters.
  2. instead of the red color, the black color is displayed.
    With Linux(OCaml 4.02.3), one error:

open_graph "600x600";;

Exception: Graphics.Graphic_failure "Cannot open display 600x600".
Thank you.
(I am not sure which category I have registered, sorry if it's not the right one)

Unable to install graphics on a fresh opam installation on Mac OS 10.14.6

Here is the output of opam install graphics

$ opam install graphics
The following actions will be performed:
  ∗ install   conf-pkg-config 1.1   [required by conf-libX11]
  ∗ install   conf-libX11     1     [required by graphics]
  ∗ install   graphics        5.0.0
  ↻ recompile ocamlfind       1.8.1 [uses graphics]
===== ∗ 3   ↻ 1 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
[ocamlfind.1.8.1] found in cache
[graphics.5.0.0] downloaded from https://github.com/ocaml/graphics/releases/download/5.0.0/graphics-5.0.0.tbz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⊘ removed   ocamlfind.1.8.1
∗ installed conf-pkg-config.1.1
∗ installed conf-libX11.1
[ERROR] The compilation of graphics failed at
        "/Users/vpoirrie/.opam/opam-init/hooks/sandbox.sh build dune build -p
        graphics -j 3 @install".

#=== ERROR while compiling graphics.5.0.0 =====================================#
# context     2.0.4 | macos/x86_64 | ocaml-system.4.09.0 | https://opam.ocaml.org#bd644e85
# path        ~/_opam/.opam-switch/build/graphics.5.0.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p graphics -j 3 @install
# exit-code   1
# env-file    ~/.opam/log/graphics-12083-48c407.env
# output-file ~/.opam/log/graphics-12083-48c407.out
### output ###
# [...]
# In file included from src/unix/text.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
#          ^~~~~~~~~~~~
# 1 error generated.
#       ocamlc src/subwindow.o (exit 2)
# (cd _build/default/src && /usr/local/bin/ocamlc.opt -g -ccopt -O2 -ccopt -fno-strict-aliasing -ccopt -fwrapv -ccopt -g -o subwindow.o subwindow.c)
# In file included from src/unix/subwindow.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
#          ^~~~~~~~~~~~
# 1 error generated.



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
┌─ The following actions failed
│ λ build graphics 5.0.0
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ⊘ remove  ocamlfind       1.8.1
│ ∗ install conf-libX11     1
│ ∗ install conf-pkg-config 1.1
└─ 

bug in fill_rect

windows 10, graphics.cma = 2015-12-09.
fill_rect 0 0 10 10 fills a square at 0 1 instead of 0 0
David Allsopp said "there is indeed a bug in the Windows implementation of Graphics.fill_rectis implemented using FillRect which states that it doesn’t include the right and bottom edge, so we should be increasing the width and height passed to it to compensate for that."

Graphics crash under Windows

Original bug ID: 7419
Reporter: Anax
Assigned to: @dra27
Status: assigned (set by @dra27 on 2016-11-22T15:49:09Z)
Resolution: open
Priority: normal
Severity: minor
Platform: Winodws
OS: Windows 10
Version: 4.02.3
Category: platform support (windows, cross-compilation, etc)
Monitored by: @gasche

Bug description

In class, we did some exercices on trees, and in the fil the teacher gave us, there were a function to trace trees (the fact that it is tree is not important).
I don't really know the module graphics.cma, but when I use it to trace a forest here, the forest is tarced, but when I when to close the windows with the space bar (there is the code let _ = read_key() in close_graph() at the end of the function) it crashes I have to launch again ocaml.
I use Windows 10 on my computer, and a friend of mine as the same problem on his Windows. At school, we use ubuntu and it works.

Steps to reproduce

As I don't really know how really works the graphics module, I give you the caml function :

let rec trace_arbre_binaire t (xmin, xmax, ymin, ymax) h =
	match t with
	| Vide -> ()
	| Noeud_Binaire (x, t1, t2) ->
			let dy = (ymax - ymin) / h in
			let xm = (xmin + xmax) / 2 in
			let s = string_of_int x in
			moveto (xm - (10 * String.length s) / 2)  ymax;
			set_color green;
			draw_string s;
			let dx = (xmax - xmin) / 2 in
			set_color yellow;
			if t1 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2) (ymax - dy + 15);
			);
			if t2 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2 + dx) (ymax - dy + 15);
			);
			trace_arbre_binaire t1 (xmin, xm, ymin, ymax - dy) (h - 1);
			trace_arbre_binaire t2 (xm, xmax, ymin, ymax - dy) (h - 1)

let voir_arbre_binaire t =
	let nx = 800
	and ny = 600 in
	open_graph (" " ^ (string_of_int nx) ^ "x" ^ (string_of_int ny));
	set_color black;
	fill_rect 0 0 nx ny;
	let k = 50 in
	trace_arbre_binaire t (k,nx - k,k,ny - k) (hauteur_arbre_binaire t);
	let _ = read_key() in close_graph();;

where the type 'a arbre is

type 'a arbre_binaire =
|  Vide
|  Noeud_Binaire of 'a * 'a arbre_binaire * 'a arbre_binaire

Additional information

(I'm a French student, so I apologize for my apporxiamtive English)

File attachments

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.