linking with iconv

430 views
Skip to first unread message

Jim Van Verth

unread,
Aug 2, 2016, 2:40:10 PM8/2/16
to skia-discuss
I'm trying to build the SkiaSDLExample on MacOS, and (after updating for the new SkSurface interface) I'm getting these errors:

Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      _SDL_iconv_REAL in libsdl.a(SDL_iconv.o)
     (maybe you meant: _SDL_iconv, _SDL_iconv_REAL , _SDL_iconv_close , _SDL_iconv_string , _SDL_iconv_open_REAL , _SDL_iconv_close_REAL , _SDL_iconv_open , _SDL_iconv_string_REAL )
  "_iconv_close", referenced from:
      _SDL_iconv_close_REAL in libsdl.a(SDL_iconv.o)
     (maybe you meant: _SDL_iconv_close, _SDL_iconv_close_REAL )
  "_iconv_open", referenced from:
      _SDL_iconv_open_REAL in libsdl.a(SDL_iconv.o)
     (maybe you meant: _SDL_iconv_open_REAL, _SDL_iconv_open )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

-liconv is one of the linker flags (set in sdl_mac.gypi), and there's a dynamic library in /usr/lib. The only thing I can think is that that library is 32-bit, but I'm not sure how to get the 64-bit library.


Jim Van Verth

unread,
Aug 2, 2016, 2:43:05 PM8/2/16
to skia-discuss
I should say that this only happens when building with Xcode. Building with ninja seems to link fine.

Mike Klein

unread,
Aug 2, 2016, 2:44:40 PM8/2/16
to skia-discuss
Can you run file on the .dylib in /usr/lib?  It'll tell us the architectures of that.  Also, run otool -L on the successfully-linked Ninja version?  That'll show what it's dynamically linked against.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Jim Van Verth

unread,
Aug 2, 2016, 2:56:35 PM8/2/16
to skia-discuss
$ file /usr/lib/libiconv.dylib
/usr/lib/libiconv.dylib: Mach-O universal binary with 2 architectures
/usr/lib/libiconv.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/lib/libiconv.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

$ otool -L out/Debug/viewer
out/Debug/viewer:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1258.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1404.46.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1258.1.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 728.9.0)

$ ls -l /usr/lib/libiconv.dylib
[...]  /usr/lib/libiconv.dylib@ -> libiconv.2.4.0.dylib
$ ls -l /usr/lib/libiconv.2.4.0.dylib
[...] /usr/lib/libiconv.2.4.0.dylib@ -> libiconv.2.dylib

So it looks like it should work.

Jim Van Verth

unread,
Aug 2, 2016, 2:58:05 PM8/2/16
to skia-discuss
Oop, wrong executable. But the result is pretty much the same:

$ otool -L out/Debug/SkiaSDLExample 
out/Debug/SkiaSDLExample:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1404.46.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1258.1.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 728.9.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1258.0.0)

Mike Klein

unread,
Aug 2, 2016, 2:59:30 PM8/2/16
to skia-discuss
Agreed, that all looks great.  It looks like the -liconv is just not getting on the link line for your libsdl.a.  Can you show the command line xcode executes?

Jim Van Verth

unread,
Aug 2, 2016, 3:05:46 PM8/2/16
to skia-discuss
Looks like it's probably related to these warnings: 
warning: skipping file '~/src/skia/git-trunk0/gyp/-lm' (unexpected file type 'text' in Frameworks & Libraries build phase)
warning: skipping file '~/src/skia/git-trunk0/gyp/-liconv' (unexpected file type 'text' in Frameworks & Libraries build phase)
warning: skipping file '~/src/skia/git-trunk0/gyp/-lobjc' (unexpected file type 'text' in Frameworks & Libraries build phase)
warning: skipping file '~/src/skia/git-trunk0/gyp/-lpthread' (unexpected file type 'text' in Frameworks & Libraries build phase)

Mike Klein

unread,
Aug 2, 2016, 3:06:34 PM8/2/16
to skia-discuss
Yep.

Jim Van Verth

unread,
Aug 3, 2016, 12:06:41 PM8/3/16
to skia-discuss
So the issue is apparently related to gyp not behaving well with Xcode 7: https://bugs.chromium.org/p/gyp/issues/detail?id=501

If I insert the library directly in Xcode, it works because it recognizes that it's a text-based dynamic library definition file. If gyp inserts it, Xcode thinks it's only text. Is there any way we could apply the patch attached to the issue locally?

I suppose a related question is: what version of Xcode are we supporting? I suspect with this fix it may not work in Xcode 6.

Mike Klein

unread,
Aug 3, 2016, 12:17:47 PM8/3/16
to skia-discuss
Probably only whatever is the very latest XCode, and whatever XCode Mike is running.
Reply all
Reply to author
Forward
0 new messages