There is a known issue on macOS where in if you have installed libiconv from other sources, the build system gets confused and mixes up the libraries and the header files and fails to compile. Since I had installed libiconv using MacPorts I got this error when building and compiling libagar:
---- MAKE ERROR ----
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/iconv.h:75:172: note: passing argument to parameter
'__outbytesleft' here
...size_t iconv (iconv_t __cd, char* * __restrict __inbuf, size_t * __restrict __inbytesleft, char* * __restrict __outbuf, size_t * __restrict __outbytesleft);
.....
[ 7%] Linking C shared library libag_core.dylib
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_ImportUnicodeICONV in string.c.o
_ExportUnicodeICONV in string.c.o
"_iconv_close", referenced from:
_ImportUnicodeICONV in string.c.o
_ExportUnicodeICONV in string.c.o
"_iconv_open", referenced from:
_ImportUnicodeICONV in string.c.o
_ExportUnicodeICONV in string.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
---- END MAKE ERROR ----
As can be seen in the MAKE error above, the header files used is from the macOS SDK (the default system iconv library) but linker is probably attempting to use the MacPorts library. When CMake generates the makefiles it detects the MacPorts libiconv:
> Performing Test Iconv_IS_BUILT_IN - Failed
> -- Found Iconv: /opt/local/lib/libiconv.dylib (found version "1.17")
The temporary solution I used was to deactivate the MacPorts library (sudo port deactivate libiconv) before generating the Makefiles with cmake. This ensured the build system didn't get confused and used the iconv from the system library.
More info on this here:
1. https://stackoverflow.com/a/57734435
Recommended:
Since it would be preferred to use the system libraries to reduce dependency, it may be prudent that the build system hardlinks to the libiconv present in /usr/lib to avoid such conflicts when building on macOS.
Thanks,
Shabeer
-- Agar mailing list [email protected] http://mail123.csoft.net/mailman/listinfo/agar
