caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlc vs. ocamlopt
@ 2007-02-27 20:35 David Brumley
  0 siblings, 0 replies; only message in thread
From: David Brumley @ 2007-02-27 20:35 UTC (permalink / raw)
  To: caml-list

Hello,
I have implemented code which calls ocaml from C.  It compiles fine with
ocamlc, but doesn't with ocamlopt. 

My original working command line is:
	ocamlfind ocamlc -package gdome2,str,ocamlgraph,extlib,unix \
	-I ../stp/ocaml -I ../stp  \
	 vine_util.cmo vine.cmo vine_typecheck.cmo stpvc.cmo \
	vine_stpvc.cmo asmir.cmo -custom -output-obj -o vine_stp_c.o \
	vine_stp_c.ml

	...

	g++ -o testexp -g testexp.o c_to_stp.o libasmir_stubs.o vine_stp_c.o \
	-L/home/dbrumley/research/valgrind/VEX \
	-L/home/dbrumley/research/vine/trunk/libasmir/src \
	-L/home/dbrumley/research/binutils-2.16.1/bfd \
	-L/home/dbrumley/research/binutils-2.16.1/libiberty \
	-L../stp/ocaml -L../stp \
	-L/usr/lib/ocaml -dl -lstpvc_stubs  -lcamlrun -lcamlidl \
	-lcurses -lm -lunix -lcamlrun \
	-lstp -lasmir -lbfd -lvex -liberty -lcamlrun -lcamlidl 

This works fine. Now for using ocamlopt.

>From what I understand from the manual and "developing applications"
book, I should be able to replace the first ocamlc with ocamlopt, drop
the -custom, and then link against asmrun instead of camlrun.  Is that
right?  

When i do that, I have:
	ocamlfind ocamlopt -package gdome2,str,ocamlgraph,extlib,unix \
	-I ../stp/ocaml -I ../stp  \
	 vine_util.cmx vine.cmx vine_typecheck.cmx stpvc.cmx \
	vine_stpvc.cmx asmir.cmx  -output-obj -o vine_stp_c.o \
	vine_stp_c.ml

...

	g++ -o testexp -g testexp.o c_to_stp.o libasmir_stubs.o vine_stp_c.o \
	-L/home/dbrumley/research/valgrind/VEX \
	-L/home/dbrumley/research/vine/trunk/libasmir/src \
	-L/home/dbrumley/research/binutils-2.16.1/bfd \
	-L/home/dbrumley/research/binutils-2.16.1/libiberty \
	-L../stp/ocaml -L../stp \
	-L/usr/lib/ocaml -dl -lstpvc_stubs  -lasmrun -lcamlidl \
	-lcurses -lm -lunix -lasmrun \
	-lstp -lasmir -lbfd -lvex -liberty -lasmrun -lcamlidl 

I get the following linker errors:
vine_stp_c.o: In function `caml_program':
(.text+0x115): undefined reference to `camlVine_stp_c__entry'
vine_stp_c.o: In function `caml_globals':
(.data+0x20c): undefined reference to `camlVine_stp_c'
vine_stp_c.o: In function `caml_data_segments':
(.data+0x56c): undefined reference to `camlVine_stp_c__data_begin'
vine_stp_c.o: In function `caml_data_segments':
(.data+0x570): undefined reference to `camlVine_stp_c__data_end'
vine_stp_c.o: In function `caml_code_segments':
(.data+0x638): undefined reference to `camlVine_stp_c__code_begin'
vine_stp_c.o: In function `caml_code_segments':
(.data+0x63c): undefined reference to `camlVine_stp_c__code_end'
vine_stp_c.o: In function `caml_frametable':
(.data+0x6a8): undefined reference to `camlVine_stp_c__frametable'
collect2: ld returned 1 exit status

A search of google turned up:
http://groups.google.com/group/fa.caml/tree/browse_frm/month/2004-12/3af05141c82b0b66?rnum=21

but I don't get how to resolve the issue (the only clue I get is someone
mentioned that ocamlopt should be defining those symbols).

I'm using ocaml 3.09.3 from fedora core 6.

Any help would be appreciated.

Thanks,
david



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-27 20:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27 20:35 ocamlc vs. ocamlopt David Brumley

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).