From a5fa81db039da889667ca4be3915c2666d9ccdce Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 26 Apr 2025 09:56:56 +0100 Subject: [PATCH] ocaml: Link mlguestfs.cma and .cmxa with local libguestfs Commit e11583a03a ("ocaml: Don't embed -L../lib/.libs in final mlguestfs.cma or .cmxa") was correct in itself, but as a side effect caused mlguestfs.cma to be linked to the system libguestfs. If system libguestfs was not installed, the build would fail entirely with: ocamlmklib -o mlguestfs \ -ldopt '-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' \ libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-guestfs-c-errnos.o ../common/utils/libguestfsocaml_a-cleanups.o ../common/utils/libguestfsocaml_a-stringlists-utils.o guestfs.cmo \ \ -lguestfs /usr/bin/ld: cannot find -lguestfs: No such file or directory Fix (from Mohamed Akram) is to add -L../lib/.libs to the -ldopt flag. This does not embed the option in the final mlguestfs.cma file, but seems to only use it while building the library. Updates: commit e11583a03ab9dc7969b6b329e0ad63524f210a26 Reported-by: Mohamed Akram Fixes: https://github.com/libguestfs/libguestfs/issues/191 --- ocaml/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index d6ef21600..220cdb2fc 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -64,13 +64,13 @@ endif stamp-mlguestfs: libguestfsocaml.a $(guestfs_cmm) $(OCAMLMKLIB) -o mlguestfs \ - -ldopt '$(LDFLAGS)' \ + -ldopt '$(LDFLAGS) -L../lib/.libs' \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ $(LTLIBINTL) \ -lguestfs if HAVE_OCAMLOPT $(OCAMLMKLIB) -o mlguestfs \ - -ldopt '$(LDFLAGS)' \ + -ldopt '$(LDFLAGS) -L../lib/.libs' \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ $(LTLIBINTL) \ -lguestfs