我正在尝试使用依赖于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
文件似乎正在查找正确的位置。可能出现什么问题?
答案 0 :(得分:5)
您可能不匹配正在使用的库/标头。看起来您使用/ usr / include中的标头编译了源代码,并尝试链接/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
进行编译