Skip to content

Instantly share code, notes, and snippets.

@pdonadeo
Last active August 29, 2015 14:12
Show Gist options
  • Save pdonadeo/bbc4a1ea176110ab93dd to your computer and use it in GitHub Desktop.
Save pdonadeo/bbc4a1ea176110ab93dd to your computer and use it in GitHub Desktop.
ctypes bug description
#!/bin/bash
gcc -ansi -Wall foo_c.c -c -o foo_c.o
ocamlfind ocamlopt \
-verbose \
-linkpkg \
-package ctypes.foreign \
foo_c.o \
foo_ml.ml \
-o foo_ml_linked_o
ar rcs libfoo_c.a foo_c.o
nm libfoo_c.a
ocamlfind ocamlopt \
-verbose \
-linkpkg \
-package ctypes.foreign \
libfoo_c.a \
foo_ml.ml \
-o foo_ml_linked_a
#include <std
open Ctypes
open Foreign
let my_foo_function = foreign "my_foo_function" (void @-> returning void)
let () =
Printf.printf "This is printed by OCaml\n%!";
my_foo_function ();
@avsm
Copy link

avsm commented Dec 24, 2014

Depending on the version of gcc, you might need to add -Wl --no-as-needed to the gcc command line; see yallop/ocaml-ctypes#49

Using the C stub generation backend of ctypes avoids this issue (see janestreet/async_ssl as an example myocamlbuild.ml that does this)

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