Skip to content

Conversation

@elias-utf8
Copy link

qcaml.0.1.3

Experimental OCaml library for quantum computing simulation
QCaml is a lightweight OCaml library for experimenting with quantum states,
gates and measurements. It provides tools for learning quantum computing
concepts and visualizing qubit states on the Bloch sphere.

Features:

  • Single qubit state representation with complex amplitudes
  • Fundamental quantum gates (Hadamard, Pauli-X/Y/Z)
  • Quantum measurements with probabilistic state collapse
  • Interactive Bloch sphere visualization using OpenGL/GLUT
  • Comprehensive test suite


🐫 Pull-request generated by opam-publish v2.7.0

@elias-utf8
Copy link
Author

Is that OK?

@jmid
Copy link
Member

jmid commented Nov 3, 2025

Is that OK?

The last commit is not right: CI is failing all over as there is no conf-glu package on the opam repository...

In comparison d660877 was passing many workflows and only failing on

  • archlinux-ocaml-5.4
    • with /usr/include/GL/freeglut_std.h:148:13: fatal error: GL/glu.h: No such file or directory
  • freebsd-14.3-ocaml-5.4
    • with (backend bisect_ppx))) # (cd _build/default && /home/opam/.opam/5.4.0/bin/ocamlmklib -g -o src/quantum_stubs src/bloch_sphere.o -ldopt -framework -ldopt OpenGL -ldopt -framework -ldopt GLUT) # ld: error: unknown argument '-framework'
  • macos-homebrew-ocaml-5.4
    • with bloch_sphere.c:1:10: fatal error: 'GL/glut.h' file not found
  • Cygwin-MinGW
    • with ** Fatal error: Cannot find file "-lfreeglut"

I would therefore suggest rolling the latest commit back, so that we can try to address the last couple of errors.

@jmid
Copy link
Member

jmid commented Nov 3, 2025

I was just looking some more at this: Can you try replacing conf-freeglut with conf-libglu?
For now, it is going to fail on Centos, but I just created #28831 to address that... 🤞

@elias-utf8
Copy link
Author

Is that OK?

The last commit is not right: CI is failing all over as there is no conf-glu package on the opam repository...

In comparison d660877 was passing many workflows and only failing on

* archlinux-ocaml-5.4
  
  * with `/usr/include/GL/freeglut_std.h:148:13: fatal error: GL/glu.h: No such file or directory`

* freebsd-14.3-ocaml-5.4
  
  * with ` (backend bisect_ppx))) # (cd _build/default && /home/opam/.opam/5.4.0/bin/ocamlmklib -g -o src/quantum_stubs src/bloch_sphere.o -ldopt -framework -ldopt OpenGL -ldopt -framework -ldopt GLUT) # ld: error: unknown argument '-framework'`

* macos-homebrew-ocaml-5.4
  
  * with `bloch_sphere.c:1:10: fatal error: 'GL/glut.h' file not found`

* Cygwin-MinGW
  
  * with `** Fatal error: Cannot find file "-lfreeglut"`

I would therefore suggest rolling the latest commit back, so that we can try to address the last couple of errors.

Okay, I rolled back to the commit d660877

@elias-utf8
Copy link
Author

elias-utf8 commented Nov 3, 2025

I was just looking some more at this: Can you try replacing conf-freeglut with conf-libglu? For now, it is going to fail on Centos, but I just created #28831 to address that... 🤞

Done, see : f869031

@jmid
Copy link
Member

jmid commented Nov 3, 2025

My bad, sorry. I got confused with all the glu.h vs glut.h errors.
As you are using glut.h, conf-freeglut should be the way to go:
https://github.com/elias-utf8/qcaml/blob/main/src/bloch_sphere.c#L1

This is the configuration package: https://github.com/ocaml/opam-repository/blob/master/packages/conf-freeglut/conf-freeglut.1/opam

From it, it should be clear why Cygwin-MinGW is failing - it is not supported, so that's one less thing to worry about...

@elias-utf8
Copy link
Author

My bad, sorry. I got confused with all the glu.h vs glut.h errors. As you are using glut.h, conf-freeglut should be the way to go: https://github.com/elias-utf8/qcaml/blob/main/src/bloch_sphere.c#L1

This is the configuration package: https://github.com/ocaml/opam-repository/blob/master/packages/conf-freeglut/conf-freeglut.1/opam

From it, it should be clear why Cygwin-MinGW is failing - it is not supported, so that's one less thing to worry about...

Yes dw, I understand. I've put back conf-freeglut. Let's see how that goes.

@elias-utf8
Copy link
Author

It seem that Arch linux CI need glu.h

# In file included from /usr/include/GL/glut.h:17,
#                  from bloch_sphere.c:1:
# /usr/include/GL/freeglut_std.h:148:13: fatal error: GL/glu.h: No such file or directory
#   148 | #   include <GL/glu.h>
#       |             ^~~~~~~~~~

But I have no clue how to do it.

@jmid
Copy link
Member

jmid commented Nov 3, 2025

I was looking at it.
The freeglut package on Arch is this one: https://archlinux.org/packages/extra/x86_64/freeglut/
According to that page it has a dependency glu: https://archlinux.org/packages/extra/x86_64/glu/
and if you press View the file list for glu at the bottom it lists GL/glu.h and glu.pc.
It seems like an Arch packaging error that a transitive dependency like that is not installed... 🤔

@jmid
Copy link
Member

jmid commented Nov 3, 2025

I was also looking at the macOS error. Interestingly, that one passes on amd64 silicon and fails on arm64 silicon.
IIRC, the library installation path differs between those two... https://docs.brew.sh/Installation

The script installs Homebrew to its default, supported, best prefix (/opt/homebrew for Apple Silicon, /usr/local for macOS Intel and...

So in this command:

# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -I/usr/local/include -g -I /Users/mac1000/.opam/5.4.0/lib/ocaml -o bloch_sphere.o -c bloch_sphere.c)
# bloch_sphere.c:1:10: fatal error: 'GL/glut.h' file not found
#     1 | #include <GL/glut.h>
#       |          ^~~~~~~~~~~
# 1 error generated.

-I/usr/local/include indeed gets things going on Intel, but won't cut it on ARM64.

Your flag-generation thus needs to distinguish the CPU-type and use something like -I/opt/homebrew/include on ARM:
https://github.com/elias-utf8/qcaml/blob/main/src/discover.ml#L13

Looking at that dispatch, it also explains the FreeBSD failures: They are currently hitting the macOS case, but may have more luck with a Linux-like case (possibly with an adjusted include path).

@elias-utf8
Copy link
Author

I'm going to post a new PR with a new release for macOS ARM64 support and FreeBSD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants