Last active
August 29, 2015 14:12
-
-
Save pdonadeo/bbc4a1ea176110ab93dd to your computer and use it in GitHub Desktop.
ctypes bug description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <std |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depending on the version of gcc, you might need to add
-Wl --no-as-needed
to the gcc command line; see yallop/ocaml-ctypes#49Using the C stub generation backend of ctypes avoids this issue (see janestreet/async_ssl as an example myocamlbuild.ml that does this)