Crates.io | libquil-sys |
lib.rs | libquil-sys |
version | 0.4.0 |
source | src |
created_at | 2023-10-16 18:13:58.711798 |
updated_at | 2023-11-16 16:46:07.095975 |
description | High-level bindings to libquil |
homepage | |
repository | https://github.com/rigetti/libquil-sys |
max_upload_size | |
id | 1004976 |
size | 165,973 |
This crate provides Rust bindings to the quilc
C library.
SBCL must be installed from source to make sure you have the libsbcl
shared library available.
sbcl
from a package manager for bootstrapping purposes.git clone --branch sbcl-2.2.0 git://git.code.sf.net/p/sbcl/sbcl
sbcl-2.2.0
is known to work. These instructions have not been tested against a newer version.sh make.sh && sh make-shared-library.sh
sbcl
.sh install.sh
to install the compiled sbcl
src/runtime/libsbcl.so
to /usr/local/lib/libsbcl.so
Quicklisp has a local projects mechanism
which we'll be using to build quilc
with it's dependencies. By default, this directory is $HOME/quicklisp/local-projects
.
If you want to use something different, you need to make sure $HOME/.sbclrc
contains the following
(replace $LISP_WORKSPACE
with the actual value):
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
#+quicklisp
(push "$LISP_WORKSPACE" ql:*local-project-directories*)
From here on, we'll refer to the local project directory you've chosen to use, whether it's the default or not, as $LISP_WORKSPACE
.
Important: The above sbcl
folder must not be in the workspace folder -- it will cause issues.
$LISP_WORKSPACE
quilc
Note: The build commands in quilc
assume you are running on MacOS and
will error on other systems.
Run the following from $LISP_WORKSPACE
:
make -C quilc
make -C quilc/lib
Optionally, run tests:
# Optional -- run tests
make -C quilc/tests/c # Builds executables to manually run
cp quilc/lib/libquilc.core quilc/lib/tests/c/
# MacOS
cp quilc/lib/libquilc.dylib quilc/lib/tests/c/
# *nix
cp quilc/lib/libquilc.so quilc/lib/tests/c/
echo "H 0" | quilc/lib/tests/c/compile-quil
libquil-sys
By default, this library assumes quilc
is in the default Quicklisp local projects directory ($HOME/quicklisp/local-projects
).
If you defined a non-default local projects directory for quilc, you need to set $QUILC_LIBRARY_PATH
to the folder
where you built the quilc library (the folder containing libquilc.dylib
). For example,
export QUILC_LIBRARY_PATH=$LISP_WORKSPACE/quilc/lib
Then, from the root of this repository:
cp "$LISP_WORKSPACE/quilc/lib/libquilc.dylib" .
cp "$LISP_WORKSPACE/quilc/lib/libquilc.core" .
cargo test