* [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
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 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 0 siblings, 1 reply; 8+ messages in thread From: Jeremy Yallop @ 2015-06-05 10:38 UTC (permalink / raw) To: Christiano F. Haesbaert; +Cc: Caml List On 5 June 2015 at 11:29, Christiano F. Haesbaert <haesbaert@haesbaert.org> wrote: > ### toto_c.c ### > ### toto_c.ml ### Both of these files will be compiled to object files called 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) should fix the problem. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 2015-06-05 10:38 ` Jeremy Yallop @ 2015-06-05 10:47 ` Christiano F. Haesbaert 2015-06-05 13:55 ` Christiano F. Haesbaert 0 siblings, 1 reply; 8+ messages in thread From: Christiano F. Haesbaert @ 2015-06-05 10:47 UTC (permalink / raw) To: Jeremy Yallop; +Cc: Caml List On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: > On 5 June 2015 at 11:29, Christiano F. Haesbaert > <haesbaert@haesbaert.org> wrote: >> ### toto_c.c ### >> ### toto_c.ml ### > > Both of these files will be compiled to object files called > 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) > should fix the problem. Hooray, great, that did the trick, thanks a lot :D. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 2015-06-05 10:47 ` Christiano F. Haesbaert @ 2015-06-05 13:55 ` Christiano F. Haesbaert 2015-06-05 14:24 ` Gabriel Scherer 0 siblings, 1 reply; 8+ messages in thread From: Christiano F. Haesbaert @ 2015-06-05 13:55 UTC (permalink / raw) To: Jeremy Yallop; +Cc: Caml List Just one more question, now with the real code, I was able to move everything to myocamlbuild, but I'm getting a warning: File "_tags", line 10, characters 12-28: Warning: the tag "linkdep(stubs.o)" is not used in any flag declaration, so it will have no effect; it may be a typo. Otherwise use `mark_tag_used` in your myocamlbuild.ml to disable this warning. ## build.sh ## ocamlbuild -use-ocamlfind all.otarget $@ ## _tags line ## <*.native>: linkdep(stubs.o) ## myocamlbuild.ml ## open Ocamlbuild_plugin;; dispatch begin function | After_rules -> pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A s]); pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A s]); pdep ["link"] "linkdep" (fun param -> [param]) | _ -> () end;; It seems to be the same case as http://stackoverflow.com/questions/25585813/mark-tag-used-warning-with-ocaml-4-02-0 Should I just use mark_tag_used ? It seems something else is wrong since the tag is actually used. On 5 June 2015 at 12:47, Christiano F. Haesbaert <haesbaert@haesbaert.org> wrote: > On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: >> On 5 June 2015 at 11:29, Christiano F. Haesbaert >> <haesbaert@haesbaert.org> wrote: >>> ### toto_c.c ### >>> ### toto_c.ml ### >> >> Both of these files will be compiled to object files called >> 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) >> should fix the problem. > > Hooray, great, that did the trick, thanks a lot :D. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 2015-06-05 13:55 ` Christiano F. Haesbaert @ 2015-06-05 14:24 ` Gabriel Scherer 2015-06-05 16:47 ` Gabriel Scherer 0 siblings, 1 reply; 8+ messages in thread From: Gabriel Scherer @ 2015-06-05 14:24 UTC (permalink / raw) To: Christiano F. Haesbaert; +Cc: Jeremy Yallop, Caml List This seems to be an ocamlbuild bug that should be reported on the bugtracker: http://caml.inria.fr/mantis/ On Fri, Jun 5, 2015 at 3:55 PM, Christiano F. Haesbaert <haesbaert@haesbaert.org> wrote: > Just one more question, now with the real code, I was able to move > everything to myocamlbuild, but I'm getting a warning: > File "_tags", line 10, characters 12-28: > Warning: the tag "linkdep(stubs.o)" is not used in any flag > declaration, so it will have no effect; it may be a typo. Otherwise > use `mark_tag_used` in your myocamlbuild.ml to disable this warning. > > ## build.sh ## > ocamlbuild -use-ocamlfind all.otarget $@ > > ## _tags line ## > <*.native>: linkdep(stubs.o) > > ## myocamlbuild.ml ## > open Ocamlbuild_plugin;; > dispatch begin function > | After_rules -> > pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A s]); > pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A s]); > pdep ["link"] "linkdep" (fun param -> [param]) > | _ -> () > end;; > > It seems to be the same case as > http://stackoverflow.com/questions/25585813/mark-tag-used-warning-with-ocaml-4-02-0 > > Should I just use mark_tag_used ? It seems something else is wrong > since the tag is actually used. > > > On 5 June 2015 at 12:47, Christiano F. Haesbaert > <haesbaert@haesbaert.org> wrote: >> On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: >>> On 5 June 2015 at 11:29, Christiano F. Haesbaert >>> <haesbaert@haesbaert.org> wrote: >>>> ### toto_c.c ### >>>> ### toto_c.ml ### >>> >>> Both of these files will be compiled to object files called >>> 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) >>> should fix the problem. >> >> Hooray, great, that did the trick, thanks a lot :D. > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 2015-06-05 14:24 ` Gabriel Scherer @ 2015-06-05 16:47 ` Gabriel Scherer [not found] ` <CAPvuBUuH0v9AUp16jy4mt-3wxBABhT2cteK2Dv81FPaABB7GeQ@mail.gmail.com> 0 siblings, 1 reply; 8+ messages in thread From: Gabriel Scherer @ 2015-06-05 16:47 UTC (permalink / raw) To: Christiano F. Haesbaert; +Cc: Jeremy Yallop, Caml List I reported and proposed a fix at http://caml.inria.fr/mantis/view.php?id=6893 On Fri, Jun 5, 2015 at 4:24 PM, Gabriel Scherer <gabriel.scherer@gmail.com> wrote: > This seems to be an ocamlbuild bug that should be reported on the bugtracker: > http://caml.inria.fr/mantis/ > > On Fri, Jun 5, 2015 at 3:55 PM, Christiano F. Haesbaert > <haesbaert@haesbaert.org> wrote: >> Just one more question, now with the real code, I was able to move >> everything to myocamlbuild, but I'm getting a warning: >> File "_tags", line 10, characters 12-28: >> Warning: the tag "linkdep(stubs.o)" is not used in any flag >> declaration, so it will have no effect; it may be a typo. Otherwise >> use `mark_tag_used` in your myocamlbuild.ml to disable this warning. >> >> ## build.sh ## >> ocamlbuild -use-ocamlfind all.otarget $@ >> >> ## _tags line ## >> <*.native>: linkdep(stubs.o) >> >> ## myocamlbuild.ml ## >> open Ocamlbuild_plugin;; >> dispatch begin function >> | After_rules -> >> pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >> pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >> pdep ["link"] "linkdep" (fun param -> [param]) >> | _ -> () >> end;; >> >> It seems to be the same case as >> http://stackoverflow.com/questions/25585813/mark-tag-used-warning-with-ocaml-4-02-0 >> >> Should I just use mark_tag_used ? It seems something else is wrong >> since the tag is actually used. >> >> >> On 5 June 2015 at 12:47, Christiano F. Haesbaert >> <haesbaert@haesbaert.org> wrote: >>> On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: >>>> On 5 June 2015 at 11:29, Christiano F. Haesbaert >>>> <haesbaert@haesbaert.org> wrote: >>>>> ### toto_c.c ### >>>>> ### toto_c.ml ### >>>> >>>> Both of these files will be compiled to object files called >>>> 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) >>>> should fix the problem. >>> >>> Hooray, great, that did the trick, thanks a lot :D. >> >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa.inria.fr/sympa/arc/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAPvuBUuH0v9AUp16jy4mt-3wxBABhT2cteK2Dv81FPaABB7GeQ@mail.gmail.com>]
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild [not found] ` <CAPvuBUuH0v9AUp16jy4mt-3wxBABhT2cteK2Dv81FPaABB7GeQ@mail.gmail.com> @ 2015-06-05 18:36 ` Gabriel Scherer 2015-06-07 20:23 ` Christiano F. Haesbaert 0 siblings, 1 reply; 8+ messages in thread From: Gabriel Scherer @ 2015-06-05 18:36 UTC (permalink / raw) To: Christiano F. Haesbaert; +Cc: caml users (Replying in-list as other people may be interested) On Fri, Jun 5, 2015 at 7:09 PM, Christiano F. Haesbaert <haesbaert@haesbaert.org> wrote: > What is the common workflow to test such diff ? > > Is there a way to pin the compiler in opam ? My personal workflow is to use my script https://github.com/gasche/opam-compiler-conf which creates an opam switch from a compiler directory, using the compiler version and git branch name to choose the switch name. Steps are: - install the opam-compiler-conf script in your $PATH *outside* opam (otherwise you will need to install it in all switches, pain) - clone the compiler somewhere (and go to the branch you want to test) - apply the patch you want to test - opam compiler-conf configure (instead of "./configure" as suggested by README) - make world.opt - opam compiler-conf install (instead of "make install" as suggested by README) This will create a switch with the compiler you installed named, for example, 4.02.2+local-git-4.02 (more generally $OCAMLVER+local-git-$BRANCHNAME). You can install opam packages and test them as in any switch. Then, if you modify the compiler again and make world.opt again, you can use - make install from the compiler directory to install the compiler without reinstalling the OPAM packages (if the binary interface didn't change and recompilation is not needed) or - opam compiler-conf reinstall to also recompile all the OPAM packages of the script (Another common way to get a switch: pull-request made against github/ocaml/ocaml automatically create a corresponding switch.) On Fri, Jun 5, 2015 at 7:09 PM, Christiano F. Haesbaert <haesbaert@haesbaert.org> wrote: > Thanks, off list, > > What is the common workflow to test such diff ? > > Is there a way to pin the compiler in opam ? > > On 5 June 2015 at 18:47, Gabriel Scherer <gabriel.scherer@gmail.com> wrote: >> I reported and proposed a fix at >> http://caml.inria.fr/mantis/view.php?id=6893 >> >> On Fri, Jun 5, 2015 at 4:24 PM, Gabriel Scherer >> <gabriel.scherer@gmail.com> wrote: >>> This seems to be an ocamlbuild bug that should be reported on the bugtracker: >>> http://caml.inria.fr/mantis/ >>> >>> On Fri, Jun 5, 2015 at 3:55 PM, Christiano F. Haesbaert >>> <haesbaert@haesbaert.org> wrote: >>>> Just one more question, now with the real code, I was able to move >>>> everything to myocamlbuild, but I'm getting a warning: >>>> File "_tags", line 10, characters 12-28: >>>> Warning: the tag "linkdep(stubs.o)" is not used in any flag >>>> declaration, so it will have no effect; it may be a typo. Otherwise >>>> use `mark_tag_used` in your myocamlbuild.ml to disable this warning. >>>> >>>> ## build.sh ## >>>> ocamlbuild -use-ocamlfind all.otarget $@ >>>> >>>> ## _tags line ## >>>> <*.native>: linkdep(stubs.o) >>>> >>>> ## myocamlbuild.ml ## >>>> open Ocamlbuild_plugin;; >>>> dispatch begin function >>>> | After_rules -> >>>> pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >>>> pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >>>> pdep ["link"] "linkdep" (fun param -> [param]) >>>> | _ -> () >>>> end;; >>>> >>>> It seems to be the same case as >>>> http://stackoverflow.com/questions/25585813/mark-tag-used-warning-with-ocaml-4-02-0 >>>> >>>> Should I just use mark_tag_used ? It seems something else is wrong >>>> since the tag is actually used. >>>> >>>> >>>> On 5 June 2015 at 12:47, Christiano F. Haesbaert >>>> <haesbaert@haesbaert.org> wrote: >>>>> On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: >>>>>> On 5 June 2015 at 11:29, Christiano F. Haesbaert >>>>>> <haesbaert@haesbaert.org> wrote: >>>>>>> ### toto_c.c ### >>>>>>> ### toto_c.ml ### >>>>>> >>>>>> Both of these files will be compiled to object files called >>>>>> 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) >>>>>> should fix the problem. >>>>> >>>>> Hooray, great, that did the trick, thanks a lot :D. >>>> >>>> -- >>>> Caml-list mailing list. Subscription management and archives: >>>> https://sympa.inria.fr/sympa/arc/caml-list >>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>>> Bug reports: http://caml.inria.fr/bin/caml-bugs ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Can't build a target with C stubs using ocamlbuild 2015-06-05 18:36 ` Gabriel Scherer @ 2015-06-07 20:23 ` Christiano F. Haesbaert 0 siblings, 0 replies; 8+ messages in thread From: Christiano F. Haesbaert @ 2015-06-07 20:23 UTC (permalink / raw) To: Gabriel Scherer; +Cc: caml users I've just test 4.02.0+trunk and can confirm it fixes the issue. Thanks again for fixing it :D. On 5 June 2015 at 20:36, Gabriel Scherer <gabriel.scherer@gmail.com> wrote: > (Replying in-list as other people may be interested) > > On Fri, Jun 5, 2015 at 7:09 PM, Christiano F. Haesbaert > <haesbaert@haesbaert.org> wrote: >> What is the common workflow to test such diff ? >> >> Is there a way to pin the compiler in opam ? > > My personal workflow is to use my script > https://github.com/gasche/opam-compiler-conf > which creates an opam switch from a compiler directory, using the > compiler version and git branch name to choose the switch name. > > Steps are: > - install the opam-compiler-conf script in your $PATH *outside* opam > (otherwise you will need to install it in all switches, pain) > - clone the compiler somewhere (and go to the branch you want to test) > - apply the patch you want to test > - opam compiler-conf configure (instead of "./configure" as suggested by README) > - make world.opt > - opam compiler-conf install (instead of "make install" as suggested by README) > > This will create a switch with the compiler you installed named, for > example, 4.02.2+local-git-4.02 (more generally > $OCAMLVER+local-git-$BRANCHNAME). You can install opam packages and > test them as in any switch. > > Then, if you modify the compiler again and make world.opt again, you can use > - make install > from the compiler directory to install the compiler without > reinstalling the OPAM packages (if the binary interface didn't change > and recompilation is not needed) > or > - opam compiler-conf reinstall > to also recompile all the OPAM packages of the script > > (Another common way to get a switch: pull-request made against > github/ocaml/ocaml automatically create a corresponding switch.) > > On Fri, Jun 5, 2015 at 7:09 PM, Christiano F. Haesbaert > <haesbaert@haesbaert.org> wrote: >> Thanks, off list, >> >> What is the common workflow to test such diff ? >> >> Is there a way to pin the compiler in opam ? >> >> On 5 June 2015 at 18:47, Gabriel Scherer <gabriel.scherer@gmail.com> wrote: >>> I reported and proposed a fix at >>> http://caml.inria.fr/mantis/view.php?id=6893 >>> >>> On Fri, Jun 5, 2015 at 4:24 PM, Gabriel Scherer >>> <gabriel.scherer@gmail.com> wrote: >>>> This seems to be an ocamlbuild bug that should be reported on the bugtracker: >>>> http://caml.inria.fr/mantis/ >>>> >>>> On Fri, Jun 5, 2015 at 3:55 PM, Christiano F. Haesbaert >>>> <haesbaert@haesbaert.org> wrote: >>>>> Just one more question, now with the real code, I was able to move >>>>> everything to myocamlbuild, but I'm getting a warning: >>>>> File "_tags", line 10, characters 12-28: >>>>> Warning: the tag "linkdep(stubs.o)" is not used in any flag >>>>> declaration, so it will have no effect; it may be a typo. Otherwise >>>>> use `mark_tag_used` in your myocamlbuild.ml to disable this warning. >>>>> >>>>> ## build.sh ## >>>>> ocamlbuild -use-ocamlfind all.otarget $@ >>>>> >>>>> ## _tags line ## >>>>> <*.native>: linkdep(stubs.o) >>>>> >>>>> ## myocamlbuild.ml ## >>>>> open Ocamlbuild_plugin;; >>>>> dispatch begin function >>>>> | After_rules -> >>>>> pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >>>>> pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A s]); >>>>> pdep ["link"] "linkdep" (fun param -> [param]) >>>>> | _ -> () >>>>> end;; >>>>> >>>>> It seems to be the same case as >>>>> http://stackoverflow.com/questions/25585813/mark-tag-used-warning-with-ocaml-4-02-0 >>>>> >>>>> Should I just use mark_tag_used ? It seems something else is wrong >>>>> since the tag is actually used. >>>>> >>>>> >>>>> On 5 June 2015 at 12:47, Christiano F. Haesbaert >>>>> <haesbaert@haesbaert.org> wrote: >>>>>> On 5 June 2015 at 12:38, Jeremy Yallop <yallop@gmail.com> wrote: >>>>>>> On 5 June 2015 at 11:29, Christiano F. Haesbaert >>>>>>> <haesbaert@haesbaert.org> wrote: >>>>>>>> ### toto_c.c ### >>>>>>>> ### toto_c.ml ### >>>>>>> >>>>>>> Both of these files will be compiled to object files called >>>>>>> 'toto_c.o'. Renaming one of them (e.g. toto_c.c to toto_c_stubs.c) >>>>>>> should fix the problem. >>>>>> >>>>>> Hooray, great, that did the trick, thanks a lot :D. >>>>> >>>>> -- >>>>> Caml-list mailing list. Subscription management and archives: >>>>> https://sympa.inria.fr/sympa/arc/caml-list >>>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>>>> Bug reports: http://caml.inria.fr/bin/caml-bugs ^ 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