-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Foreign can't find symbols statically linked in #167
Comments
I have been using, e.g.: int unix_unistd_unlink(const char *pathname) {
int retval;
caml_release_runtime_system();
retval = unlink(pathname);
caml_acquire_runtime_system();
return retval;
}
value unix_unistd_unlink_ptr(value _) {
UNUSED(_);
return caml_copy_int64((intptr_t)(void *)unix_unistd_unlink);
} let local ?check_errno addr typ =
coerce (ptr void) (funptr ?check_errno typ) (ptr_of_raw_address addr)
external unix_unistd_unlink_ptr : unit -> int64 = "unix_unistd_unlink_ptr"
let unlink =
let c = local ~check_errno:true (unix_unistd_unlink_ptr ())
PosixTypes.(string @-> returning int)
in
fun pathname ->
try ignore (c pathname)
with Unix.Unix_error(e,_,_) -> raise (Unix.Unix_error (e,"unlink",pathname)) |
Adding $ clang -c -fPIC foo.c
$ ocamlfind ocamlopt -linkpkg -package ctypes,ctypes.foreign -cclib -Wl,-E foo.o bar.ml -o bar
$ ./bar
42 |
Sweet! 👍 |
Yes, that's the one. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two files:
foo.c
:bar.ml
:Compiling
foo
as shared works:But not linking it in:
Binding it via:
... picks it up, however.
Can I overcome this somehow?
The text was updated successfully, but these errors were encountered: