caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Link problems when startup from C++
@ 2013-03-24  8:00 Kakadu
  2013-03-24 13:09 ` [Caml-list] " Kakadu
  0 siblings, 1 reply; 2+ messages in thread
From: Kakadu @ 2013-03-24  8:00 UTC (permalink / raw)
  To: Caml List

Hey

My OCaml code uses Unix findlib package and I compile it like this

ocamlfind opt -package compiler-libs.common,unix -linkpkg -output-obj
-dstartup -I ../_build ../_build/qml_wrap.cmxa \
        -ccopt -L`ocamlc -where` -ccopt -lunix \
        DataItem.cmx MainModel.cmx MiniModel.cmx program.cmx  -linkall
-o camlcode.o -verbose
Effective set of compiler predicates:
pkg_compiler-libs,pkg_compiler-libs.common,pkg_unix,autolink,native
+ ocamlopt.opt -output-obj -dstartup -I ../_build -ccopt
-L/home/kakadu/.opam/4.00.1/lib/ocaml -ccopt -lunix -linkall -o
camlcode.o -verbose -I
/home/kakadu/.opam/4.00.1/lib/ocaml/compiler-libs
/home/kakadu/.opam/4.00.1/lib/ocaml/compiler-libs/ocamlcommon.cmxa
/home/kakadu/.opam/4.00.1/lib/ocaml/unix.cmxa ../_build/qml_wrap.cmxa
DataItem.cmx MainModel.cmx MiniModel.cmx program.cmx
+ as -o '/tmp/camlstartup3ada06.o' 'camlcode.o.startup.s'
+ ld -r  -o 'camlcode.o' '/tmp/camlstartup3ada06.o' 'program.o'
'MiniModel.o' 'MainModel.o' 'DataItem.o' '../_build/qml_wrap.a'
'/home/kakadu/.opam/4.00.1/lib/ocaml/unix.a'
'/home/kakadu/.opam/4.00.1/lib/ocaml/compiler-libs/ocamlcommon.a'
'/home/kakadu/.opam/4.00.1/lib/ocaml/stdlib.a'

It seems that Unix should be statically linked to 'camlcode.o'. After
that I want to build executable.

g++ -L$QT5_ROOT/qtbase/lib -lQt5Core -lQt5Qml -lQt5Quick -lQt5Gui
-L"`ocamlc -where`" -lunix \
        ../_build/stubs.o DataItem_c.o moc_DataItem_c.o MainModel_c.o
moc_MainModel_c.o MiniModel_c.o moc_MiniModel_c.o camlcode.o main.o
-lm  -ldl -lasmrun \
        -o main

And I get many error like this:

camlcode.o: In function `camlProgram__files_in_dir_1009':
(.text+0x399a): undefined reference to `unix_opendir'
/home/kakadu/.opam/4.00.1/build/ocaml/otherlibs/unix/unix.ml:644:
undefined reference to `unix_close'
camlcode.o: In function `camlUnix__fun_2465':
/home/kakadu/.opam/4.00.1/build/ocaml/otherlibs/unix/unix.ml:644:
undefined reference to `unix_close'
camlcode.o: In function `camlUnix__fun_2157':
/home/kakadu/.opam/4.00.1/build/ocaml/otherlibs/unix/unix.ml:644:
undefined reference to `unix_setsid'
camlcode.o: In function `camlUnix__fun_2159':
/home/kakadu/.opam/4.00.1/build/ocaml/otherlibs/unix/unix.ml:644:
undefined reference to `unix_tcflow'
camlcode.o: In function `camlUnix__fun_2161':
/home/kakadu/.opam/4.00.1/build/ocaml/otherlibs/unix/unix.ml:644:
undefined reference to `unix_tcflush'
etc.

Any ideas what I have done wrong? How to link to unix correctly?

Kind regards,
Kakadu

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

end of thread, other threads:[~2013-03-24 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-24  8:00 [Caml-list] Link problems when startup from C++ Kakadu
2013-03-24 13:09 ` [Caml-list] " Kakadu

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