Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocamlopt and linking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-12 (09:04)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] ocamlopt and linking
> I'm trying to link an ocamlopt-generated object file into a C program by 
> following instructions on
> 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