Não é mais possível fazer postagens ou usar assinaturas novas da Usenet nos Grupos do Google. O conteúdo histórico continua disponível.
Dismiss

[Caml-list] state of native dynlink on os x

123 visualizações
Pular para a primeira mensagem não lida

Alan Schmitt

não lida,
15 de fev. de 2012, 06:17:2615/02/2012
para caml-list
Hello,

As I'm using more and more programs that use native dynlink, I'm trying
to understand what is the state of things on os x. According to this
message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink does
not work on 10.5 and above. However, if I read correctly this patch
http://caml.inria.fr/mantis/view.php?id=4863 it is enabled for 64 bits
architectures. As the patch is in godi, I built a version of ocaml with
it, and I'm having mixed results.

For some very simple files, things seem to work fine. But if I compile
why3 with it (current git version), I get some errors when running
why3config:

== Found /usr/local/lib/why3/plugins/genequlin.cmxs ==
The plugin /usr/local/lib/why3/plugins/genequlin.cmxs dynlink failed :
Dynlink error : error loading shared library:
dlopen(/usr/local/lib/why3/plugins/genequlin.cmxs, 134): Symbol not
found: _camlRandom
Referenced from: /usr/local/lib/why3/plugins/genequlin.cmxs
Expected in: flat namespace
in /usr/local/lib/why3/plugins/genequlin.cmxs
== Found /usr/local/lib/why3/plugins/tptp.cmxs ==
The plugin /usr/local/lib/why3/plugins/tptp.cmxs dynlink failed :
Dynlink error : error loading shared library:
dlopen(/usr/local/lib/why3/plugins/tptp.cmxs, 134): Symbol not found:
_camlParsing
Referenced from: /usr/local/lib/why3/plugins/tptp.cmxs
Expected in: flat namespace
in /usr/local/lib/why3/plugins/tptp.cmxs
== Found /usr/local/lib/why3/plugins/tptpfof.cmxs ==
The plugin /usr/local/lib/why3/plugins/tptpfof.cmxs dynlink failed :
Dynlink error : error loading shared library:
dlopen(/usr/local/lib/why3/plugins/tptpfof.cmxs, 134): Symbol not found:
_camlString
Referenced from: /usr/local/lib/why3/plugins/tptpfof.cmxs
Expected in: flat namespace
in /usr/local/lib/why3/plugins/tptpfof.cmxs

Note that there was a warning when compiling why3:
ld: warning: -read_only_relocs cannot be used with x86_64

So I'm a bit confused as to the current state of things. My questions
are:

- is native dynlink on os x 64 bits architecture supported in ocaml
3.13dev?
- if so, why do I get the ld warning and why does linking fails
sometimes?
- if not, is there hope it will be supported in the future?

Thanks a lot,

Alan

--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Daniel Bünzli

não lida,
15 de fev. de 2012, 07:34:5715/02/2012
para Alan Schmitt, caml-list
Can't precisely answer your questions but :
> to understand what is the state of things on os x. According to this
> message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink does
> not work on 10.5 and above.
>

At least here it does work without problems on 10.6.8. with this [1] config.

Best,

Daniel

[1]
> ocamlc -config

version: 3.12.0
standard_library_default: /usr/local/lib/ocaml
standard_library: /usr/local/lib/ocaml
standard_runtime: /usr/local/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
bytecomp_c_libraries: -lcurses -lpthread
native_c_compiler: gcc -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_libraries:
native_pack_linker: ld -r -arch x86_64 -o
ranlib: ranlib
cc_profile: -pg
architecture: amd64
model: default
system: macosx
asm: as -arch x86_64
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true

Alan Schmitt

não lida,
15 de fev. de 2012, 09:16:5715/02/2012
para Daniel Bünzli, caml-list
On 15 Feb 2012, at 13:34, Daniel Bünzli wrote:

> Can't precisely answer your questions but :
>> to understand what is the state of things on os x. According to this
>> message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink
>> does
>> not work on 10.5 and above.
>>
>
> At least here it does work without problems on 10.6.8. with this [1]
> config.

OK, so I guess this is a bug with why3. I'll report it there.

Thanks,

Alan

Alan Schmitt

não lida,
17 de fev. de 2012, 01:48:2517/02/2012
para caml-list
Hello,

Following a suggestion by Daniel Bünzli, I used the minimum example
from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that
native dynlink does work.

However two questions remain. I get `ld: warning: -read_only_relocs
cannot be used with x86_64` each time I link natively. Does this mean I
should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch
there is applied to my version of caml)?

Also, when running why3, I get some undefined symbols (_camlRandom,
_camlParsing, _camlString). Where are these symbols defined?

Thanks,

Pierre-Alexandre Voye

não lida,
27 de fev. de 2012, 12:50:1827/02/2012
para Damien Doligez, caml-list
2012/2/27 Damien Doligez <damien....@inria.fr>

> Hi Alan,
> > Following a suggestion by Daniel Bünzli, I used the minimum example from
> http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native
> dynlink does work.
> >
> > However two questions remain. I get `ld: warning: -read_only_relocs
> cannot be used with x86_64` each time I link natively. Does this mean I
> should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch
> there is applied to my version of caml)?
>
> Which version of Mac OS X, which version of OCaml, and what is the output
> of configure?
>
I had it in Mac Lion ( 10.7.3 - 11.3.0 Darwin Kernel Version 11.3.0: Thu
Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64 )
Example, compiling Ocsigen :
(end of make...)
ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread -I
./baselib -I ../http -package lwt.ssl -package lwt.extra -package
netstring -package findlib -package cryptokit -package tyxml -package
tyxml.parser -package dynlink -package tyxml.syntax -I .
./baselib/parsecommandline.cma ../baselib/baselib.cma
./baselib/polytables.cma ../http/http.cma ocsigenserver.cma server_main.cmo
File "_none_", line 1, characters 0-1:
Error: Error while linking
/opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4):
Reference to undefined global `Dynlink'
make[4]: *** [ocsigenserver] Error 2
make[3]: *** [all] Error 2
make[2]: *** [all] Error 2
make[1]: *** [do-ocsigenserver-build] Error 2
make: *** [.ocsigenserver-build] Error 2


> > Also, when running why3, I get some undefined symbols (_camlRandom,
> _camlParsing, _camlString). Where are these symbols defined?
>
> Looks like modules of the standard library, right ?
>
>
> Here, i have :
File "_none_", line 1, characters 0-1:
Error: Cannot find file dynlink.cmxa
make: *** [bin/why3config.opt] Error 2
make: *** Waiting for unfinished jobs....

configure of why3 :
$ ./configure --enable-menhirlib --enable-doc
checking executable suffix... <none>
checking for ocamlc... ocamlc
ocaml version is 3.12.1
ocaml library path is /opt/local/lib/ocaml
checking for ocamlopt... ocamlopt
checking ocamlopt version... ok
checking for ocamlc.opt... ocamlc.opt
checking ocamlc.opt version... ok
checking for ocamlopt.opt... ocamlopt.opt
checking ocamlc.opt version... ok
checking for ocamldep... ocamldep
checking for ocamldep.opt... ocamldep.opt
checking for ocamllex... ocamllex
checking for ocamllex.opt... ocamllex.opt
checking for ocamlyacc... ocamlyacc
checking for ocamldoc... ocamldoc
checking for ocamldoc.opt... ocamldoc.opt
checking for camlp5o... camlp5o
checking for ocamlfind... yes
checking for menhir... menhir
ocamlfind found menhir library in /opt/local/lib/ocaml/site-lib/menhirLib
checking for rubber... no
configure: WARNING: cannot find rubber
ocamlfind found lablgtk2 in /opt/local/lib/ocaml/lablgtk2
ocamlfind found sqlite3 in /opt/local/lib/ocaml/site-lib/sqlite3
checking for coqc... coqc
checking Coq version... 8.3pl2
checking for /usr/local/lib/coq/kernel/term.cmi... yes
ocamlfind found ocamlgraph in /opt/local/lib/ocaml/site-lib/ocamlgraph
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/config.sh
config.status: creating doc/version.tex
config.status: creating share/provers-detection-data.conf
config.status: creating META
config.status: executing chmod commands

Summary
-----------------------------------------
OCaml version : 3.12.1
OCaml library path : /opt/local/lib/ocaml
Verbose make : no
Why IDE : yes
Why bench tool : yes
Why documentation : no
Why plugins : yes
Coq plugin support : no (not yet implemented)
TPTP parser : yes
Menhir library : yes
hypothesis selection : yes
profiling : no
localdir : no

>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


--
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

Pierre-Alexandre Voye

não lida,
28 de fev. de 2012, 05:33:0728/02/2012
para David MENTRE, Damien Doligez, caml-list
It doesn't change anything :
make clean
/configure --enable-menhirlib --enable-doc
make
..

ocamlopt.opt -a -w Aer-29 -dtypes -I src -I
/opt/local/lib/ocaml/site-lib/ocamlgraph -o src/why3.cmxa src/why3.cmx
Ocamlopt src/main.ml
Linking bin/why3.opt
File "_none_", line 1, characters 0-1:
Error: Cannot find file dynlink.cmxa
make: *** [bin/why3.opt] Error 2

2012/2/28 David MENTRE <dme...@linux-france.org>

> Hello,
>
> 2012/2/27 Pierre-Alexandre Voye <ontol...@gmail.com>:
> > make: *** Waiting for unfinished jobs....
>
> Are you using parallel compilation of Why3 (make -j /n/?). I had
> compilation issue with parallel compilation of Why3. However it might
> not be related to your issue or it might have been fixed in the
> meantime.
>
> Best regards,
> david

Alan Schmitt

não lida,
28 de fev. de 2012, 10:36:1628/02/2012
para Damien Doligez, caml-list
On 27 févr. 2012, at 16:43, Damien Doligez wrote:

> Hi Alan,
>> Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work.
>>
>> However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)?
>
> Which version of Mac OS X, which version of OCaml, and what is the output of configure?

OS X 10.7.3, ocaml 3.12.1-godi2. About the output of configure, I'm trying to see how to get it from godi, in the meantime here is my ocamlc -config:

version: 3.12.1
standard_library_default: /Users/schmitta/godi/lib/ocaml/std-lib
standard_library: /Users/schmitta/godi/lib/ocaml/std-lib
standard_runtime: /Users/schmitta/godi/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
bytecomp_c_libraries: -lcurses -lpthread
native_c_compiler: gcc -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_libraries:
native_pack_linker: ld -r -arch x86_64 -o
ranlib: ranlib
cc_profile: -pg
architecture: amd64
model: default
system: macosx
asm: as -arch x86_64
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true


>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined?
>
> Looks like modules of the standard library, right ?

Do they need to be loaded manually, or should they be loaded automatically by the native linker?

Alan Schmitt

não lida,
29 de fev. de 2012, 03:33:4429/02/2012
para Damien Doligez, caml-list
On 27 févr. 2012, at 16:43, Damien Doligez wrote:

> Hi Alan,
>> Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work.
>>
>> However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)?
>
> Which version of Mac OS X, which version of OCaml, and what is the output of configure?

Here is the output of configure:

Configuring for a i686-apple-darwin11.3.0 ...
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
Wow! A 64 bit architecture!
This is a little-endian architecture.
Doubles can be word-aligned.
64-bit integers can be word-aligned.
Native division and modulus have round-towards-zero semantics, will use them.
ranlib found
#! appears to work in shell scripts
POSIX signal handling found.
expm1() and log1p() found.
getrusage() found.
times() found.
termcap functions found (with libraries '-lcurses')
You have BSD sockets.
socklen_t is defined in <sys/socket.h>
inet_aton() found.
IPv6 is supported.
unistd.h found.
off_t is defined in <sys/types.h>
dirent.h found.
rewinddir() found.
lockf() found.
mkfifo() found.
getcwd() found.
getwd() found.
getpriority() found.
utime() found.
utimes() found.
dup2() found.
fchmod() found.
truncate() found.
sys/select.h found.
select() found.
symlink() found.
waitpid() found.
wait4() found.
getgroups() found.
setgroups() found.
initgroups() found.
POSIX termios found.
Asynchronous I/O are supported.
setitimer() found.
gethostname() found.
uname() found.
gettimeofday() found.
mktime() found.
setsid() found.
putenv() found.
setlocale() and <locale.h> found.
dlopen() found.
Dynamic loading of shared libraries is supported.
mmap() found.
Replay debugger supported.
System stack overflow can be detected.
POSIX threads library supported.
Options for linking with POSIX threads: -lpthread
sigwait() found
Bytecode threads library supported.
Location of X11 include files: /usr/X11R6/include/X11
Options for linking with X11: -L/usr/X11R6/lib -lX11
NDBM found (in /usr/include)
Configuring LablTk...
tcl.h and tk.h version 8.5 found with "".
Tcl/Tk libraries found.
BFD library not found, 'objinfo' will be unable to display info on .cmxs files

** Configuration summary **

Directories where Objective Caml will be installed:
binaries.................. /Users/schmitta/godi/bin
standard library.......... /Users/schmitta/godi/lib/ocaml/std-lib
manual pages.............. /Users/schmitta/godi/man (with extension .1)
Configuration for the bytecode compiler:
C compiler used........... gcc
options for compiling..... -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
options for linking....... -lcurses -lpthread
shared libraries are supported
options for compiling..... -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
command for building...... gcc -bundle -flat_namespace -undefined suppress -read_only_relocs suppress -o lib.so /a/path objs
Configuration for the native-code compiler:
hardware architecture..... amd64
OS variant................ macosx
C compiler used........... gcc
options for compiling..... -D_FILE_OFFSET_BITS=64 -D_REENTRANT
options for linking.......
assembler ................ as -arch x86_64
preprocessed assembler ... gcc -arch x86_64 -c
native dynlink ........... true
profiling with gprof ..... supported
Source-level replay debugger: supported
Additional libraries supported:
unix str num dynlink bigarray systhreads threads graph dbm labltk
Configuration for the "num" library:
target architecture ...... amd64 (asm level 1)
Configuration for the "graph" library:
options for compiling .... -I/usr/X11R6/include
options for linking ...... -L/usr/X11R6/lib -lX11
Configuration for the "labltk" library:
use tcl/tk version ....... 8.5
options for compiling ....
options for linking ...... -ltk8.5 -ltcl8.5

Damien Doligez

não lida,
7 de mar. de 2012, 05:55:2607/03/2012
para Alan Schmitt, caml-list
Hi Alan,

> OS X 10.7.3, ocaml 3.12.1-godi2.

You need to apply the patch from this PR:

http://caml.inria.fr/mantis/view.php?id=4863

From your "configure" output, I presume godi uses the patch from this PR:

http://caml.inria.fr/mantis/view.php?id=5379

but it's incomplete.

-- Damien

Alan Schmitt

não lida,
7 de mar. de 2012, 10:15:1607/03/2012
para Damien Doligez, caml-list
On 7 mars 2012, at 11:55, Damien Doligez wrote:

> Hi Alan,
>
>> OS X 10.7.3, ocaml 3.12.1-godi2.
>
> You need to apply the patch from this PR:
>
> http://caml.inria.fr/mantis/view.php?id=4863
>
> From your "configure" output, I presume godi uses the patch from this PR:
>
> http://caml.inria.fr/mantis/view.php?id=5379
>
> but it's incomplete.

Thanks, it did work indeed (and I've reported this upstream to the godi list).

Alan

Alan Schmitt

não lida,
8 de mar. de 2012, 06:14:1708/03/2012
para caml-list list
On 27 févr. 2012, at 16:43, Damien Doligez wrote:

>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined?
>
> Looks like modules of the standard library, right ?

Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first?

In other words, is this a bug in why3, or in ocaml?

Alan Schmitt

não lida,
8 de mar. de 2012, 09:16:4708/03/2012
para caml-list list
On 8 mars 2012, at 12:13, Alan Schmitt wrote:

> On 27 févr. 2012, at 16:43, Damien Doligez wrote:
>
>>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined?
>>
>> Looks like modules of the standard library, right ?
>
> Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first?
>
> In other words, is this a bug in why3, or in ocaml?

Trying to get to the bottom of this, here is what I've done.

- Adapting the minimal example from http://caml.inria.fr/mantis/view.php?id=5093 I checked that I can load a plugin that uses a function from Random.
- I then tried to load a why3 plugin. It fails because it cannot find some symbol (_camlWhy3), and I could not find how to compile things to make sure why3.cmxa is linked with the plugin.
- Getting back to the basics, I tried to create a small archive of my own, which I would use in a plugin, and this is where I'm stuck. I have the following files:

test.ml:

let f () = "foo"

plugin.ml:

let s = Test.f ()
let () = print_endline s

loader.ml:

let load f =
try
Dynlink.loadfile f
with Dynlink.Error e -> print_endline (Dynlink.error_message e)

let () = load "plugin.cmxs"

to build everything, I do (I tried adding test.cmxa everywhere, to no avail. Everything lives in the same, current directory):

ocamlopt.opt -a -o test.cmxa test.ml
ocamlopt.opt -c -linkall -o plugin.cmx test.cmxa plugin.ml
ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs
ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native

When I run "./loader.native", I get:

no implementation available for Test

I googled this error and could only find references to problem related to the (deprecated) Dynlink.add_interfaces, which is not even supposed to work natively.

What am I doing wrong?

Pierre-Alexandre Voye

não lida,
8 de mar. de 2012, 09:24:3308/03/2012
para Alan Schmitt, caml-list list
In Mac Lion, i get :

$ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs
ld: warning: -read_only_relocs cannot be used with x86_64
$ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native
File "loader.ml", line 1, characters 0-1:
Error: Cannot find file dynlink.cmxa

2012/3/8 Alan Schmitt <alan.s...@polytechnique.org>

Alan Schmitt

não lida,
8 de mar. de 2012, 09:36:1108/03/2012
para Pierre-Alexandre Voye, caml-list list
On 8 mars 2012, at 15:23, Pierre-Alexandre Voye wrote:

> In Mac Lion, i get :
>
> $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs
> ld: warning: -read_only_relocs cannot be used with x86_64
> $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native
> File "loader.ml", line 1, characters 0-1:
> Error: Cannot find file dynlink.cmxa

You first need to patch ocaml with this:
http://caml.inria.fr/mantis/view.php?id=4863

Pierre-Alexandre Voye

não lida,
8 de mar. de 2012, 10:51:3808/03/2012
para Alan Schmitt, caml-list list
After applying the patch, recompiling, your example works fine, but while
compiling Ocsigen framework, at the end, I have :

ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread -I
./baselib -I ../http -package lwt.ssl -package lwt.extra -package
netstring -package findlib -package cryptokit -package tyxml -package
tyxml.parser -package dynlink -package tyxml.syntax -I .
./baselib/parsecommandline.cma ../baselib/baselib.cma
./baselib/polytables.cma ../http/http.cma ocsigenserver.cma server_main.cmo
File "_none_", line 1, characters 0-1:
Error: Error while linking
/opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4):
Reference to undefined global `Dynlink'

2012/3/8 Alan Schmitt <alan.s...@polytechnique.org>

> On 8 mars 2012, at 15:23, Pierre-Alexandre Voye wrote:
>
> > In Mac Lion, i get :
> >
> > $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs
> > ld: warning: -read_only_relocs cannot be used with x86_64
> > $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native
> > File "loader.ml", line 1, characters 0-1:
> > Error: Cannot find file dynlink.cmxa
>
> You first need to patch ocaml with this:
> http://caml.inria.fr/mantis/view.php?id=4863
>
> Alan
>



--

Gabriel Scherer

não lida,
8 de mar. de 2012, 11:17:5408/03/2012
para Alan Schmitt, caml-list list
This error is not Mac-related (I can reproduce it on my Debian).
I believe it is a result from the "link-by-need" semantics of the .cma
and .cmxa: loader.ml does not explicitly depend on test, so when
producing the executable test.cmxa isn't linked (modules included
cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a
runtime dependency of one of the other modules).

I can remove the error by either:
- compiling to "test.cmx" instead of "test.cmxa"
- or adding a dummy dependency in loader.ml:
let () = ignore (Test.f)

I am not familiar with the building of dynlink plugins (no idea what
"-shared" does and whether you are expecting the compiled code for
Test to end up linked inside "plugin.cmxs" instead of linked at
executable compile time), so there may be another solution for this.
But I remember other people mentioning this "explicit dependency"
thing in the past; the dummy dependency is probably the right thing to
do if you consider Test a library that come with the loader
application and should be usable by all dynlinked module. If it is
morally local to "plugin", there must be another approach.

Jérémie Dimino

não lida,
8 de mar. de 2012, 11:20:1208/03/2012
para Pierre-Alexandre Voye, caml-list list
Le Thu, 8 Mar 2012 16:50:59 +0100,
Pierre-Alexandre Voye <ontol...@gmail.com> a écrit :

> ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread
> -I ../baselib -I ../http -package lwt.ssl -package lwt.extra -package
> netstring -package findlib -package cryptokit -package tyxml -package
> tyxml.parser -package dynlink -package tyxml.syntax -I .
> ../baselib/parsecommandline.cma ../baselib/baselib.cma
> ../baselib/polytables.cma ../http/http.cma ocsigenserver.cma
> server_main.cmo File "_none_", line 1, characters 0-1:
> Error: Error while linking
> /opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4):
> Reference to undefined global `Dynlink'

It is probably because there is a missing dependency from
camlp4.lib to dynlink. You can check whether it is the case or not with:

$ ocamlfind query -r -p-format camlp4.lib

If it is not, add dynlink to the requires field of camlp4.lib
in the camlp4 META's file.

--
Jérémie

Jérémie Dimino

não lida,
8 de mar. de 2012, 11:26:3408/03/2012
para Gabriel Scherer, Alan Schmitt, caml-list list
Le Thu, 8 Mar 2012 17:16:30 +0100,
Gabriel Scherer <gabriel...@gmail.com> a écrit :

> This error is not Mac-related (I can reproduce it on my Debian).
> I believe it is a result from the "link-by-need" semantics of the .cma
> and .cmxa: loader.ml does not explicitly depend on test, so when
> producing the executable test.cmxa isn't linked (modules included
> .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a
> runtime dependency of one of the other modules).
>
> I can remove the error by either:
> - compiling to "test.cmx" instead of "test.cmxa"
> - or adding a dummy dependency in loader.ml:
> let () = ignore (Test.f)

You can also use -linkall for building loader.native. In fact -linkall
should always be used when you are using dynlink plugins.

--
Jérémie

Alan Schmitt

não lida,
8 de mar. de 2012, 11:32:2208/03/2012
para Jérémie Dimino, Gabriel Scherer, caml-list list
On 8 mars 2012, at 17:25, Jérémie Dimino wrote:

> Le Thu, 8 Mar 2012 17:16:30 +0100,
> Gabriel Scherer <gabriel...@gmail.com> a écrit :
>
>> This error is not Mac-related (I can reproduce it on my Debian).
>> I believe it is a result from the "link-by-need" semantics of the .cma
>> and .cmxa: loader.ml does not explicitly depend on test, so when
>> producing the executable test.cmxa isn't linked (modules included
>> .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a
>> runtime dependency of one of the other modules).
>>
>> I can remove the error by either:
>> - compiling to "test.cmx" instead of "test.cmxa"
>> - or adding a dummy dependency in loader.ml:
>> let () = ignore (Test.f)
>
> You can also use -linkall for building loader.native. In fact -linkall
> should always be used when you are using dynlink plugins.

That was it. Thanks a lot!

Alan
0 nova mensagem