Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000456OCamlOCaml generalpublic2001-07-28 16:322001-07-31 18:48
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000456: ocamlopt 3.01 on win32 (msvc) requires *.lib with *.cmxa
Description
Two related bugs:

1. I'm trying to compile a project with a foo.cmxa file that was generated without any .ml files, so there's no object code. I do have a .mli interface and a separate bar.lib C implementation library. I can build the foo.cmxa fine, but when I go for the final link, ocamlopt ... foo.cmxa ... causes a linker error (in msvc's link.exe), complaining that there's no foo.lib to go along with the foo.cmxa. foo.cmxa does not seem to reference a foo.lib internally, so this seems to be something ocamlopt is adding?

If I create an empty dummy foo.lib, the project links fine.

2. If there's a foo.lib existing when foo.cmxa (the library without any objects) is built, the original gets erased. This means I need to name the C implementation file something completely different so that the ocamlopt -a doesn't delete it.

Chris

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002317)
administrator (administrator)
2001-07-30 14:31

> 1. I'm trying to compile a project with a foo.cmxa file that was
> generated without any .ml files, so there's no object code. I do
> have a .mli interface and a separate bar.lib C implementation
> library. I can build the foo.cmxa fine, but when I go for the final
> link, ocamlopt ... foo.cmxa ... causes a linker error (in msvc's
> link.exe), complaining that there's no foo.lib to go along with the
> foo.cmxa. foo.cmxa does not seem to reference a foo.lib internally,
> so this seems to be something ocamlopt is adding?

Yes. Normally, for each .ml file, ocamlopt produces both a .cmx file
(compilation info) and a .obj file (the actual code), and ocamlopt -a
produces both a .cmxa file (compilation info for the library) and
a .lib file (the actual library file containing the code). The .lib
file is built by calling Microsoft's LIB program, but apparently it
refuses to create an empty library. (The Unix "ar" program that is
called for the same purposes has no problems with that.)

The LIB documentation doesn't indicate any way to change this
behavior. I'd recommend making the .cmxa non empty, by having .ml
files that implement the .mli files associated with your library.
I understand that in simple cases the .ml files will be just copies of
the .mli files, containing only type and external declarations.
Experience shows however that it rarely remains so, and often some
initialization code needs to be added to the library, resulting in
non-trivial .ml files. So, consider this as an investment for the
future :-)

> 2. If there's a foo.lib existing when foo.cmxa (the library without
> any objects) is built, the original gets erased.

This is normal: ocamlopt -a erases foo.lib in preparation for
rebuilding it using LIB. It's just that LIB doesn't do its part of
the job :-)

> This means I need
> to name the C implementation file something completely different so
> that the ocamlopt -a doesn't delete it.

It is recommended procedure anyway: the library containing the code
for the C part of your library should be named differently than that
generated by ocamlopt -a, which contains code for the Caml part.

Best wishes,

- Xavier Leroy

(0002318)
administrator (administrator)
2001-07-31 18:48

LIB lossage w.r.t. empty libraries.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker