dillo icon indicating copy to clipboard operation
dillo copied to clipboard

MacOS linker error, might need more info in the README

Open ghovax opened this issue 2 years ago • 5 comments

When compiling with libs installed via Homebrew, I get this error that I couldn't fix (even with the way suggested on HackerNews):

ld: Undefined symbols:
  _iconv, referenced from:
      _Decode_charset in decode.o
      DilloHtmlForm::encodeText(__tag_iconv_t*, Dstr**) in form.o
  _iconv_close, referenced from:
      _Decode_charset_free in decode.o
      DilloHtmlForm::buildQueryData(DilloHtmlInput*) in form.o
  _iconv_open, referenced from:
      _a_Decode_charset_init in decode.o
      DilloHtmlForm::buildQueryData(DilloHtmlInput*) in form.o
      DilloHtmlForm::buildQueryData(DilloHtmlInput*) in form.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How would you suggest fixing it? Adding LDFLAGS -L/opt/homebrew/opt/libiconv/lib didn't work.

ghovax avatar Jan 03 '24 09:01 ghovax

Could you paste the output of the "./configure" or upload the config.log file? The procedure to locate the iconv library seems to be failing in your system or we are mixing libiconv / libc iconv for some targets.

As a workaround you could try adding CPPFLAGS=-DLIBICONV_PLUG to the configure arguments so libiconv uses the same API as the one in the libc.

rodarima avatar Jan 03 '24 11:01 rodarima

I tried as you suggested, nothing changed. Here's the config.log: https://pastebin.com/mEFG5fMc.

ghovax avatar Jan 03 '24 12:01 ghovax

Thanks, I'll keep the log here too in case it expires: log.txt

From the log, libiconv seems to be available in your system:

PATH: /opt/homebrew/opt/libiconv/bin/

And it is found by the configure:

configure:7396: checking for iconv.h
configure:7396: gcc -c -g -O2 -I/opt/homebrew/Cellar/openssl@3/3.2.0_1/include conftest.c >&5
configure:7396: $? = 0
configure:7396: result: yes
configure:7406: checking for iconv_open in -liconv
configure:7435: gcc -o conftest -g -O2 -I/opt/homebrew/Cellar/openssl@3/3.2.0_1/include -L/opt/homebrew/Cellar/openssl@3/3.2.0_1/lib conftest.c -liconv   >&5
configure:7435: $? = 0
configure:7447: result: yes

I'm thinking your issue may be related to this: https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx

We don't provide yet a --with-iconv option but it should be equivalent of using:

./configure 'LDFLAGS=-L/opt/homebrew/opt/libiconv/lib' 'CPPFLAGS=-I/opt/homebrew/opt/libiconv/include'

rodarima avatar Jan 08 '24 21:01 rodarima

I have the same issue. Installed via Homebrew on an Intel based Mac.

orbit-stabilizer avatar Jan 19 '24 20:01 orbit-stabilizer

This issue is likely happening because there are several iconv libraries installed in your system, which are incompatible among themselves and they are in the same library directory also used for other dependencies of Dillo. A way to discover multiple iconv installations is by running which -a iconv or better (but slower) find / -name "libiconv.so*".

When the autoconf script finds one iconv library that is working, assumes that it will work for the next discovery steps. This assumption is not correct as adding the search path for other libraries may switch the selection of the iconv library, and should be corrected so that once a iconv library is found, the full path is used to link to that one specifically. Otherwise, other -L flags used for other libraries will cause the linker to choose another iconv library that is not compatible with objects already built.

We could spend some effort trying to fix the iconv search procedure, but I believe it would be better invested if we instead switch to another build system like cmake which already has the logic to search and pin the full iconv library path (and also would solve some other problems).

However, I don't want to introduce those big changes for the 3.1 release, so the proper solution would have to wait a bit. For now, fiddling with the CFLAGS and LDFLAGS or removing the other iconv libraries should be a viable workaround.

rodarima avatar Feb 01 '24 18:02 rodarima