Closed xoolive closed 8 years ago
poke @jbedouet
This line is at least necessary under Linux, so that the resulting executable is linked towards C++ and not C. When used with Windows, flexlink
does the linking, regardless of C++/C.
The best option may be to create a C interface (extern "C"
) uphill (for the functions called by the OCaml callbacks) so that the linking is more direct. Would it be?
Also, it is weird that the linkopts
option is not considered when creating an interpreter through ocamlmktop
. See example below:
xo at tsugaru in ~
$ ocaml
OCaml version 4.02.0
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "geodesy";;
/home/xo/.opam/4.02.0+PIC/lib/geodesy: added to search path
/home/xo/.opam/4.02.0+PIC/lib/geodesy/geodesy-byte.cma: loaded
# open Geodesy;;
# SphericalGeodesy.distance 0. 0. 0. (1./.60. *. acos(-1.)/. 180.);;
Error: The external function `sph_distance' is not available
xo at tsugaru in ~
$ ocamlfind ocamlmktop -package geodesy -linkpkg -cc "/usr/bin/c++"
xo at tsugaru in ~
$ ./a.out
OCaml version 4.02.0
# open Geodesy;;
Error: Unbound module Geodesy
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "geodesy";;
/home/xo/.opam/4.02.0+PIC/lib/geodesy: added to search path
/home/xo/.opam/4.02.0+PIC/lib/geodesy/geodesy-byte.cma: loaded
# open Geodesy;;
# SphericalGeodesy.distance 0. 0. 0. (1./.60. *. acos(-1.)/. 180.);;
- : float = 1853.2487774093122
#
The
linkopts = "-cc @CMAKE_CXX_COMPILER@"
inocaml/META.in
seems irrelevant, and even buggy when compiling/ocamlfind-ing with Windows.The linker should be specified instead of the compiler (hence
flexlink
), and their options as well (if need be.)See,
-chain mingw
or-chain cygwin
.Question: