I am trying to build a library while my code used to be an executable but now I need to execute my function from another repository.
My intent is to produce a .cmxa file from my main source file ComponentDefinition.ml (so ComponentDefinition.cmxa). This file would be the library for my project.
So my makefile look like this
OCAMLFIND=ocamlfind
OCAMLC=$(OCAMLFIND) ocamlopt
CMO=cmx
CMA=cmxa
INCLUDES= -package yojson -package opium -package logs -package str -package ounit2 -package lwt_ppx -package cohttp-lwt-unix -package uuidm
OCAMLFLAGS= -thread -linkpkg -g -w -u-s-y $(INCLUDES)
SRC=Value.ml CustomMediaType.ml TypeFormatConstraints.ml TypesFormatsConstraintsManager.ml Parameter.ml Parameters.ml Return.ml Returns.ml Response_.ml InternalReturns.ml TaskDef.ml DbConnector.ml Route.ml RoutePaging.ml FetchUrlRoute.ml RawContentInputRoute.ml RouteManager.ml Task.ml ComponentRouteBuilder.ml ComponentInput.ml ComponentOutput.ml Component.ml ComponentManager.ml SelfDescribe.ml MicroService.ml ComponentDefinition.ml
test: $(SRC:.ml=.$(CMO))
$(OCAMLC) $(OCAMLFLAGS) -o test $(SRC:.ml=.$(CMO)) Test.ml
app: $(SRC:.ml=.$(CMO)) Main.ml
$(OCAMLC) $(OCAMLFLAGS) -o app $(SRC:.ml=.$(CMO)) Main.ml
lib: $(SRC:.ml=.$(CMO))
$(OCAMLC) $(OCAMLFLAGS) -a $(SRC:.ml=.$(CMO)) ComponentDefinition.ml
# Common rules
.SUFFIXES: .ml .mli .$(CMO) .cmi
%.cmi: %.mli
$(OCAMLC) $(OCAMLFLAGS) -c $<
%.$(CMO): %.ml
$(OCAMLC) $(OCAMLFLAGS) -c $<
# Clean up
clean:
rm -f *.cm[ioax]
rm -f *.o
test and app targets work well, but when I try lib target, I get the error
ocamlfind ocamlopt -thread -linkpkg -g -w -u-s-y -package yojson -package opium -package logs -package str -package ounit2 -package lwt_ppx -package cohttp-lwt-unix -package uuidm -a Value.cmx CustomMediaType.cmx TypeFormatConstraints.cmx TypesFormatsConstraintsManager.cmx Parameter.cmx Parameters.cmx Return.cmx Returns.cmx Response_.cmx InternalReturns.cmx TaskDef.cmx DbConnector.cmx Route.cmx RoutePaging.cmx FetchUrlRoute.cmx RawContentInputRoute.cmx RouteManager.cmx Task.cmx ComponentRouteBuilder.cmx ComponentInput.cmx ComponentOutput.cmx Component.cmx ComponentManager.cmx SelfDescribe.cmx MicroService.cmx ComponentDefinition.cmx ComponentDefinition.ml
Option -a cannot be used with .cmxa input files.
This error is not very documented on the web, how could it be bypassed ?
There is no .cmxa input file in my project (trying to produce one!)