Hi all!
I'm building a static library named lightclient on macOS via this command invocation:
nim c --app:staticlib --header:lightclient.h --noMain lightclient.nim
During the final stage, when the build process invokes ar tool, i get this error:
Error: execution of an external program failed: 'ar @lightclient_linkerArgs.txt'
Seems that is because Nim compiler by default invokes version of ar from Xcode command line tools, which does not support reading parameters from files. I tried modifying the path for Nim compiler invocation:
PATH=/usr/local/opt/binutils/bin:$PATH nim c ...`
which works. However, later on, when i try to link the resulting static library with another executable, i get ld linker errors, complaining that
ld: warning: ignoring file liblightclient.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
so i'm at loss now.
Can someone please shed some light on this? Maybe there is a way to tell Nim to use macOS's default tools without fiddling with the PATH, or some other options?
Thanks a lot.
Are you linking external libraries and if so did you build those or were they provided?
You may be running into a versioning issue; -mmacosx-version-min flag may be the culprit.
Have you tried building a trivial static lib, exporting a proc or two, just to confirm that nim itself builds the static lib correctly?
I just tried this on my laptop, with no issues. objdump -a shows that there are several object files within the resulting library archive file.