We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5386

Summary: macOS 11: final linking fails with Framework CoreHaptic with SDK 10.14
Product: SDL Reporter: Dominik Reichardt <sdl-bugzilla>
Component: hapticAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: HG 2.0   
Hardware: x86_64   
OS: macOS 10.15   
Attachments: config.log
configure patch
config.log after the configure.patch

Description Dominik Reichardt 2020-12-09 19:59:42 UTC
Created attachment 4560 [details]
config.log

When you use the sDK 10.14 to compile SDL2 final linking fails because Framework CoreHaptic is not come with SDK < 10.15
I have not tested on a macOS 10.14 system. Probably works, I think you check macOS version but not SDK version.

config.log attached.

./configure summary and make error:
-en SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   : mmx 3dnow sse sse2 sse3
Audio drivers   : disk dummy coreaudio
Video drivers   : dummy cocoa metal x11(dynamic) opengl opengl_es2 opengl vulkan
X11 libraries   : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers   :
Enable virtual joystick APIs : YES
Using libsamplerate : NO
Using libudev       : NO
Using dbus          : NO
Using ime           : NO
Using ibus          : NO
Using fcitx         : NO

% make -j9 -s
mkdir build
  CC     build/SDL.lo
...
  CC     build/SDL_test_random.lo
  LTLINK build/libSDL2main.la
  LTLINK build/libSDL2.la
ld: framework not found CoreHaptics
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build/libSDL2.la] Error 1
Comment 1 Ozkan Sezer 2020-12-09 20:58:23 UTC
Created attachment 4562 [details]
configure patch

Does the attached patch help?  (Sam: can you review?)
Comment 2 Dominik Reichardt 2020-12-09 21:09:03 UTC
Created attachment 4563 [details]
config.log after the configure.patch
Comment 3 Dominik Reichardt 2020-12-09 21:13:03 UTC
After this patch it fails with some iconv error.

Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
      _SDL_iconv_REAL in SDL_iconv.o
  "_libiconv_close", referenced from:
      _SDL_iconv_close_REAL in SDL_iconv.o
  "_libiconv_open", referenced from:
      _SDL_iconv_open_REAL in SDL_iconv.o
ld: symbol(s) not found for architecture x86_64
Comment 4 Ozkan Sezer 2020-12-09 21:26:40 UTC
(In reply to Dominik Reichardt from comment #2)
> Created attachment 4563 [details]
> config.log after the configure.patch

So the patch seems to do its job properly.
Comment 5 Ozkan Sezer 2020-12-09 21:27:58 UTC
(In reply to Dominik Reichardt from comment #3)
> After this patch it fails with some iconv error.
> 
> Undefined symbols for architecture x86_64:
>   "_libiconv", referenced from:
>       _SDL_iconv_REAL in SDL_iconv.o
>   "_libiconv_close", referenced from:
>       _SDL_iconv_close_REAL in SDL_iconv.o
>   "_libiconv_open", referenced from:
>       _SDL_iconv_open_REAL in SDL_iconv.o
> ld: symbol(s) not found for architecture x86_64

This one, I have no idea...

Maybe if you provide preprocessed version of SDL_iconv.c
that would help?
Comment 6 Ozkan Sezer 2020-12-09 21:35:34 UTC
Looked at my local copy of MacOSX10.14.sdk - unlike libiconv from FSF,
iconv.h from that SDK does not add 'lib' prefix to iconv functions, so
this is weird...
Comment 7 Ozkan Sezer 2020-12-09 21:46:33 UTC
OK, looking at your config.log, you have -I/opt/x86_64/include
and -L/opt/x86_64/lib in configury tests.
Do you have a libiconv installation under /opt/x86_64/ ?
If you do, it is possible that clang is including iconv.h from
/opt/x86_64/include (it most probably defines iconvXX functions
to libiconvXXX), but ld is picking wrong incompatible libiconv
from /opt/SDKs/MacOSX10.14.sdk/usr/lib
Comment 8 Sam Lantinga 2020-12-10 04:31:36 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/0f6b27018208
Comment 9 Dominik Reichardt 2020-12-10 06:48:18 UTC
my iconv problem came from having macports symlinked to /opt/x11 (which I did for some other tests).
Sorry for the noise, without doing this and having the Xquartz' X11 release there makes everything work.
Thanks for the fast fix!