From: "Christiano F. Haesbaert" <haesbaert@haesbaert.org>
To: caml-list@inria.fr
Subject: [Caml-list] Can't build a target with C stubs using ocamlbuild
Date: Fri, 5 Jun 2015 12:29:57 +0200 [thread overview]
Message-ID: <CAPvuBUu3yfA=FwqfzoHGpxYV=CLp00SnLUKpWcN02KsFqe-7dA@mail.gmail.com> (raw)
Hi there,
I can't seem to be able to use a C stub in my project, I was following this:
http://l-lang.blogspot.de/2012/08/incorporating-c-code-in-ocaml-project.html
After I've failed to follow the original documentation, if this is not
the correct list for such inquiries please inform me the correct one
I'm using OS X 10.10 with opam and compiler 4.02.1 from opam.
These are the contents of the files and the attempt at building it,
they can also be found at http://haesbaert.org/toto.tar.gz
### toto_c.c ###
#include <stdio.h>
void
toto(void)
{
printf("Hello from C\n");
}
### toto_c.ml ###
external toto_a: unit -> unit = "toto";;
let toto_b () = toto_a(); toto_a();;
### main.ml ###
Toto_c.toto_a();;
Toto_c.toto_b();;
## build.sh ##
#!/bin/sh
ocamlbuild -classic-display toto_c.o
ocamlbuild -classic-display -lflags toto_c.o main.native
### building... ###
/Users/haesbaert/.opam/4.02.1/bin/ocamldep.opt -modules toto_c.ml >
toto_c.ml.depends
/Users/haesbaert/.opam/4.02.1/bin/ocamlc.opt -c -o toto_c.cmo toto_c.ml
/Users/haesbaert/.opam/4.02.1/bin/ocamlopt.opt -c -o toto_c.cmx toto_c.ml
/Users/haesbaert/.opam/4.02.1/bin/ocamldep.opt -modules main.ml >
main.ml.depends
/Users/haesbaert/.opam/4.02.1/bin/ocamlc.opt -c -o main.cmo main.ml
/Users/haesbaert/.opam/4.02.1/bin/ocamlopt.opt -c -o main.cmx main.ml
/Users/haesbaert/.opam/4.02.1/bin/ocamlopt.opt toto_c.o toto_c.cmx
main.cmx -o main.native
+ /Users/haesbaert/.opam/4.02.1/bin/ocamlopt.opt toto_c.o toto_c.cmx
main.cmx -o main.native
Undefined symbols for architecture x86_64:
"_toto", referenced from:
.L100 in main.o
.L100 in toto_c.o
.L101 in toto_c.o
_camlToto_c__1 in toto_c.o
.L100 in toto_c.o
.L101 in toto_c.o
_camlToto_c__1 in toto_c.o
...
(maybe you meant: _camlToto_c__toto_b_1009)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
File "caml_startup", line 1:
Error: Error during linking
Command exited with code 2.
next reply other threads:[~2015-06-05 10:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 10:29 Christiano F. Haesbaert [this message]
2015-06-05 10:38 ` Jeremy Yallop
2015-06-05 10:47 ` Christiano F. Haesbaert
2015-06-05 13:55 ` Christiano F. Haesbaert
2015-06-05 14:24 ` Gabriel Scherer
2015-06-05 16:47 ` Gabriel Scherer
[not found] ` <CAPvuBUuH0v9AUp16jy4mt-3wxBABhT2cteK2Dv81FPaABB7GeQ@mail.gmail.com>
2015-06-05 18:36 ` Gabriel Scherer
2015-06-07 20:23 ` Christiano F. Haesbaert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPvuBUu3yfA=FwqfzoHGpxYV=CLp00SnLUKpWcN02KsFqe-7dA@mail.gmail.com' \
--to=haesbaert@haesbaert.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox