caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Can't build a target with C stubs using ocamlbuild
@ 2015-06-05 10:29 Christiano F. Haesbaert
  2015-06-05 10:38 ` Jeremy Yallop
  0 siblings, 1 reply; 8+ messages in thread
From: Christiano F. Haesbaert @ 2015-06-05 10:29 UTC (permalink / raw)
  To: caml-list

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-06-07 20:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05 10:29 [Caml-list] Can't build a target with C stubs using ocamlbuild Christiano F. Haesbaert
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).