On Tue, Dec 29, 2009 at 10:55:49AM -0500, lin hong wrote:
> I'm struggling with this for few days.
> 
> We have a static C library, instead of "libsomename.a", it's "somename.a",
> so we could not link it in the usually way like "-lsomename".
> In myocamlbuild.ml, I did try to add it's head files dir into cflags, and
> "/somelib/dir/somename.a" to clibs. This works for Mac, however, in Linux,
> it won't pass the linking process.

I suspect this is because the order of arguments on the linker command line is
wrong.  I think it is the case that when using the GNU linker, and object file
foo.o has unresolved symbols that are to be found in static library bar.a, that
you have to specify foo.o on the command line before bar.a.  (This means you
may have to specify a static library multiple times.)  However it looks like
Mac OS X is different.  Reading the manual page for ld on Mac OS X says:

  "Unlike traditional linkers, ld will continually search a static library
  while linking. There is no need to specify a static library multiple times
  on the command line."

which is maybe why your link is working on the Mac -- even if you haven't
specified the .a multiple times, perhaps it is going back and re-examining
the static library when it encounters the object later on the command line.

You shouldn't have to specify the full path to the static library; at least
on a system using the GNU linker you should be able to use something like:

        -static -lsomename -dynamic

in the middle of the command.

Just as a side point, an output of the linker errors pasted into an email
is always useful for this sort of diagnosis.

Hope that helps,
Mark

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to