-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Description
- cocos2d-x version: latest
v4
- devices test on: N/A (applies to
mac
target only) - developing environments
- NDK version: N/A
- Xcode version: N/A
- VS version: N/A
- browser type and version: N/A
Issue description
On OS X Mojave there appears to be an issue related to the iconv
library. When creating a project and attempting to build it for mac
there is a linker error:
[100%] Linking CXX executable bin/MyGame/MyGame.app/Contents/MacOS/MyGame
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
cocos2d::FontAtlas::conversionU32TOGB2312(std::__1::basic_string<char32_t, std::__1::char_traits<char32_t>, std::__1::allocator<char32_t> > const&, std::__1::unordered_map<unsigned int, unsigned int, std::__1::hash<unsigned int>, std::__1::equal_to<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, unsigned int> > >&) in libcocos2d.a(CCFontAtlas.cpp.o)
"_iconv_close", referenced from:
cocos2d::FontAtlas::~FontAtlas() in libcocos2d.a(CCFontAtlas.cpp.o)
"_iconv_open", referenced from:
cocos2d::FontAtlas::conversionU32TOGB2312(std::__1::basic_string<char32_t, std::__1::char_traits<char32_t>, std::__1::allocator<char32_t> > const&, std::__1::unordered_map<unsigned int, unsigned int, std::__1::hash<unsigned int>, std::__1::equal_to<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, unsigned int> > >&) in libcocos2d.a(CCFontAtlas.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/MyGame/MyGame.app/Contents/MacOS/MyGame] Error 1
make[1]: *** [CMakeFiles/MyGame.dir/all] Error 2
make: *** [all] Error 2
I found the relevant section in CocosConfigDepend.cmake
and the issue is that:
find_library(ICONV_LIBRARY iconv)
message(WARNING ${ICONV_LIBRARY})
Will find /usr/local/lib/libiconv.dylib
, which does not export those symbols. Changing it to iconv
(which should pick up whatever system library) fixes the issue.
It does export the functions, but under a different name:
$ r2 /usr/local/lib/libiconv.dylib
-- Enable asm.trace to see the tracing information inside the disassembly
[0x00000000]> iE
[Exports]
Num Paddr Vaddr Bind Type Size Name
000 0x000f3230 0x000f3230 GLOBAL FUNC 0 __libiconv_version
001 0x00003e80 0x00003e80 GLOBAL FUNC 0 _iconv_canonicalize
002 0x00002f80 0x00002f80 GLOBAL FUNC 0 _libiconv
003 0x00003010 0x00003010 GLOBAL FUNC 0 _libiconv_close
004 0x00001000 0x00001000 GLOBAL FUNC 0 _libiconv_open
005 0x00003040 0x00003040 GLOBAL FUNC 0 _libiconv_open_into
006 0x00025b70 0x00025b70 GLOBAL FUNC 0 _libiconv_set_relocation_prefix
007 0x00003860 0x00003860 GLOBAL FUNC 0 _libiconvctl
008 0x00003aa0 0x00003aa0 GLOBAL FUNC 0 _libiconvlist
Metadata
Metadata
Assignees
Labels
No labels