我正在尝试使用依赖于iconv的CMake构建一个库。我已经在Macports上安装了它,但是每当尝试构建库时,都会出现以下错误:
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
我有一个
FindIconv.cmake
文件,似乎在正确的位置。可能出什么问题了? 最佳答案
您可能与使用的库/标题不匹配。看来您使用/ usr / include中的 header 编译了源代码,并试图链接到/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
确保使用-I / opt / local / include进行编译