Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* ocamlopt and linking
@ 2004-12-12  7:29 Taras
  2004-12-12  8:24 ` [Caml-list] " Taras
  2004-12-12  9:04 ` Xavier Leroy
  0 siblings, 2 replies; 3+ messages in thread
From: Taras @ 2004-12-12  7:29 UTC (permalink / raw)
  To: caml-list

Hi,
I'm trying to link an ocamlopt-generated object file into a C program by 
following instructions on http://caml.inria.fr/ocaml/htmlman/manual032.html

Here is a small testcase: http://glek.net/~taras/os.tar.bz2

Currently it seems that main is already defined in libasmrun and some 
symbols are missing from it.

cc -L /usr/lib/ocaml -lasmrun -ldl -lm -lcurses -o prog modwrap.o 
mod_from_ml.o main.c
/home/taras/tmp/ccWVigi0.o(.text+0x0): In function `main':
: multiple definition of `main'
/usr/lib/ocaml/libasmrun.a(main.o)(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 39 in 
/usr/lib/ocaml/libasmrun.a(main.o) to 96 in /home/taras/tmp/ccWVigi0.o
mod_from_ml.o(.text+0x584): In function `caml_curry6_5':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0x772): In function `caml_curry7_6':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0x77c): In function `caml_curry7_6':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0xd5e): In function `camlPervasives__min_49':
: undefined reference to `caml_lessequal'
mod_from_ml.o(.text+0xd9e): In function `camlPervasives__max_52':
: undefined reference to `caml_greaterequal'
mod_from_ml.o(.text+0x3144): In function `camlList__mem_185':
: undefined reference to `caml_compare'
mod_from_ml.o(.text+0x31da): In function `camlList__assoc_193':
: undefined reference to `caml_compare'
mod_from_ml.o(.text+0x32d6): In function `camlList__mem_assoc_203':
: undefined reference to `caml_compare'
mod_from_ml.o(.text+0x336d): In function `camlList__remove_assoc_213':
: undefined reference to `caml_compare'
mod_from_ml.o(.text+0x4893): In function `camlString__compare_176':
: undefined reference to `caml_compare'
mod_from_ml.o(.text+0x6a28): In function `camlPrintf__doprn_187':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0x6c08): In function `camlPrintf__doprn_224':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0x6d88): In function `camlPrintf__doprn_253':
: undefined reference to `caml_extra_params'
mod_from_ml.o(.text+0x72b3): In function `camlPrintf__scan_format_142':
: undefined reference to `caml_extra_params'
collect2: ld returned 1 exit status


Thanks,
Taras


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

* Re: [Caml-list] ocamlopt and linking
  2004-12-12  7:29 ocamlopt and linking Taras
@ 2004-12-12  8:24 ` Taras
  2004-12-12  9:04 ` Xavier Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Taras @ 2004-12-12  8:24 UTC (permalink / raw)
  Cc: caml-list

Taras wrote:

> Hi,
> I'm trying to link an ocamlopt-generated object file into a C program 
> by following instructions on 
> http://caml.inria.fr/ocaml/htmlman/manual032.html
>
> Here is a small testcase: http://glek.net/~taras/os.tar.bz2
>
Neither ocamlc, nor ocamlopt binaries seem to link for me. Am I making a 
mistake somewhere?
In the above testcase,
make MODE=caml attempts to link with ocamlc-generated .o & libcamlrun.a

make MODE=asm uses ocamlopt & libasmrun.a

In above 2 cases I get a different sets of missing symbols.

Thanks,
Taras


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

* Re: [Caml-list] ocamlopt and linking
  2004-12-12  7:29 ocamlopt and linking Taras
  2004-12-12  8:24 ` [Caml-list] " Taras
@ 2004-12-12  9:04 ` Xavier Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 2004-12-12  9:04 UTC (permalink / raw)
  To: Taras; +Cc: caml-list

> I'm trying to link an ocamlopt-generated object file into a C program by 
> following instructions on http://caml.inria.fr/ocaml/htmlman/manual032.html
> Currently it seems that main is already defined in libasmrun and some 
> symbols are missing from it.
> cc -L /usr/lib/ocaml -lasmrun -ldl -lm -lcurses -o prog modwrap.o 
> mod_from_ml.o main.c

You have a linking order problem.  Remember that Unix linkers are
*very* sensitive to the order of libraries on the command-line.
(See the Info page for gcc, section "Options for linking", for more info.)
Just put the libraries (-lxxx) last on the line and everything will
work fine.

- Xavier Leroy


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

end of thread, other threads:[~2004-12-12  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-12  7:29 ocamlopt and linking Taras
2004-12-12  8:24 ` [Caml-list] " Taras
2004-12-12  9:04 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox