[m-users.] Linking error with mercury-json library

Sean Charles (emacstheviking) objitsu at gmail.com
Thu Sep 1 04:42:31 AEST 2022


Hi,

I built a library by Julien Fischer that manages JSON, my issue I think is one of not understanding the linking process!

In my project folder, I have this:

  ./deps
    /curl
    /json


I built the libcurl from source, that's linking just fine, I am using a Makefile to do it but I think that the option I have used to tell it where the json library can be found must be wrong, here is how I built the library according to the instructions:

make INSTALL_PREFIX=/Users/seancharles/Documents/code/mercury/mercury-libcurl/deps/json install

and sure enough, under my ./deps/json/ folder I have the following:

➜  mercury-libcurl ll deps/json/lib/mercury
total 0
drwxr-xr-x  12 seancharles  staff   384B 30 Aug 08:15 inc
drwxr-xr-x  75 seancharles  staff   2.3K 30 Aug 08:15 ints
drwxr-xr-x   3 seancharles  staff    96B 30 Aug 08:15 lib
drwxr-xr-x   3 seancharles  staff    96B 30 Aug 08:15 modules

and the leaf folders appear to contain lots of relevant looking code, however when I run the make I get the following linker error:

➜  mercury-libcurl make
mmc -s hlc.gc -O4 -E  --mld ./deps/json/lib/mercury -lcurl  --make mcurl
Making mcurl
** Error making `mcurl'.
Undefined symbols for architecture arm64:
  "<predicate 'json.from_string'/2 mode 0>", referenced from:
      <predicate 'main'/2 mode 0> in mcurl.o
  "<type_ctor_info for type 'json.value'/0>", referenced from:
      <predicate 'main'/2 mode 0> in mcurl.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mcurl] Error 1


My Makefile is one I use for all my Mercury projects I start, which is where I suspect the issue lies, if anybody can tell me what I need to do I would be very grateful...tomorrow morning I have surgery on my liver to remove Putin, my tumour, and as soon as I wake up, if I can move, I can hack, and ...well, you know... hacking, a great pain killer.

BIN=mcurl
DEPS=mcurl.m curl.m
FILES=$(patsubst %.m,%,$(DEPS))
GENEXT=d,o,mh,err,c,c_date,mh,mih
GRADE=hlc.gc
# this one links to the extras folder in case you need it.
# but note that you may need to change the /usr/local/MERCURY-ROOT/..
# FLAGS=--ml posix --mld /usr/local/mercury-rotd-2021-04-15/extras/lib/mercury -s $(GRADE) -O4 -E
$CURL_INC=`pkg-config --cflags libcurl`
$CURL_LIB=`pkg-config --libs libcurl`
FLAGS=-s $(GRADE) -O4 -E $(CURL_INC) --mld ./deps/json/lib/mercury
LDFLAGS=-lcurl

all:: $(BIN)

install:: $(BIN)
	mv -f -v $(BIN) $(HOME)/bin/

%: %.m $(DEPS)
	mmc $(FLAGS) --make $@

$(BIN): $(DEPS)
	mmc $(FLAGS) $(LDFLAGS) $(CURL_LIB) --make $(BIN)
	mv -fv $(BIN) $(BIN)

clean::
	rm -rf Mercury
	rm -fv $$(for x in $(FILES); do echo $$x.{$(GENEXT)}; done)
	rm -fv $(BIN)

:)

All the best,
Sean.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220831/344c1539/attachment.html>


More information about the users mailing list