What are the practical differences between the following?
Option 1: Just include the .o files in the cmxa file with a call to ocamlopt
all: main
stub.o: stub.c
gcc -I$$(opam var lib)/ocaml -c stub.c
test.cmx: test.ml
ocamlopt -c test.ml
test.cmxa: test.cmx stub.o
ocamlopt -cclib -levent -a stub.o test.cmx -o test.cmxa
main.cmx: test.ml
ocamlopt -c main.ml
main: test.cmxa main.cmx
ocamlopt test.cmxa main.cmx -o main
.PHONY: clean
clean:
rm -f *.cmx *.cmi *.cmxa *.o main
Option 2: Build a library out of the .o files and link to them (using ocamlmklib)
all: main
stub.o: stub.c
gcc -I$$(opam var lib)/ocaml -c stub.c
test.cmx: test.ml
ocamlopt -c test.ml
test.cmxa: test.cmx stub.o
ocamlmklib -cclib -levent test.cmx stub.o -o test
main.cmx: main.ml
ocamlopt -c main.ml
main: test.cmxa main.cmx
ocamlopt -I ./ test.cmxa main.cmx -o main
.PHONY: clean
clean:
rm -f *.cmx *.cmi *.cmxa *.o *.so *.a main
My assumption is option 1 is required for bytecode support. If all I care about is native support is there any practical difference?
Thanks