I'm trying to build a library with CMake that depends on iconv. I've installed it with Macports but whenever I try to build the library I get the following error:
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_mariadb_convert_string in my_charset.c.o
"_iconv_close", referenced from:
_mariadb_convert_string in my_charset.c.o
"_iconv_open", referenced from:
_mariadb_convert_string in my_charset.c.o
ld: symbol(s) not found for architecture x86_64
I have a FindIconv.cmake
file that seems to be looking in the right place. What could go wrong?
You are likely mismatching which library/headers you are using. It looks like you compiled your source code using headers from /usr/include and are trying to link against /opt/local/lib/libiconv.dylib
~ $ nm -m /usr/lib/libiconv.dylib | grep iconv_close
0000000000002ea4 (__TEXT,__text) external _iconv_close
~ $ nm -m /opt/local/lib/libiconv.dylib | grep iconv_close
0000000000003ec0 (__TEXT,__text) external _libiconv_close
Make sure you compile with -I/opt/local/include