SFML community forums
Help => General => Topic started by: Milerius on June 18, 2018, 02:55:36 pm
-
Hello
Today I wanted to use SFML in static on my mac, only it seems that I crash immediately at the launch of the program. So I decided to reproduce the error with an all-fresh build of the sfml.
Here is the procedure:
git clone https://github.com/SFML/SFML
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DSFML_BUILD_EXAMPLES:BOOL=ON ..
make -j
cd examples/window
./window
There is the fullstacktrace:
2018-06-18 14:46:19.399 window[11527:6544367] -[SFOpenGLView enableKeyRepeat]: unrecognized selector sent to instance 0x7fe0b762c5c0
2018-06-18 14:46:19.399 window[11527:6544367] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SFOpenGLView enableKeyRepeat]: unrecognized selector sent to instance 0x7fe0b762c5c0'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff41f37fcb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff68bd5c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff41fd0a24 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff41eae610 ___forwarding___ + 1456
4 CoreFoundation 0x00007fff41eadfd8 _CF_forwarding_prep_0 + 120
5 window 0x000000010af7f34a -[SFOpenGLView initWithFrame:fullscreen:] + 122
6 window 0x000000010af808c5 -[SFWindowController setupWindowWithMode:andStyle:] + 437
7 window 0x000000010af801e4 -[SFWindowController initWithMode:andStyle:] + 356
8 window 0x000000010af82a96 _ZN2sf4priv15WindowImplCocoaC2ENS_9VideoModeERKNS_6StringEmRKNS_15ContextSettingsE + 230
9 window 0x000000010af761f3 _ZN2sf4priv10WindowImpl6createENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE + 67
10 window 0x000000010af75215 _ZN2sf6Window6createENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE + 469
11 window 0x000000010af752d7 _ZN2sf6WindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE + 119
12 window 0x000000010af6f74d main + 173
13 window 0x000000010af6f694 start + 52
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1] 11527 abort ./window
Computer:
macOs High Sierra 10.13.3
Compiler:
./clang++ -v
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
There seems to be an error in the objective-c code, I do not know if it's a regression since 2.5.0 I've never used SFML in static on this platform before
Thanks you for your help !
-
I asked Hiura again and he confirmed that static linking is not supported on macOS.
-
Might not be officially supported, but does work - Milerius can you try adding -all_load to your other linker flags?
-
You'll have to make sure it doesn't change the load order of SFML libraries and the one from the system or you might have some issues. Frankly, seen how easy it is to create an application bundle, I wouldn't spend my time on something that isn't officially supported and could break at any moment or on a slightly different environment. ;)
-
there's a bit of ambiguity here if I understand correctly:
static libraries are supported by Apple (and presumably by SFML too?)
statically linked binaries are not supported by Apple (and therefore not by SFML either?)
I think OP is trying the former? I wouldn't claim to be an expert, so please correct me if I'm wrong
-
No, you "statically" link against static libraries. There's only one concept, which SFML does support at all and that is not recommended by Apple on macOS (iOS is somewhat different).
-
https://developer.apple.com/library/archive/qa/qa1118/_index.html
along with other resources is where I was getting the info from. And indeed, if I try and create a statically linked binary, I get the expected error.
Using SFML static libraries however doesn't error, and has the expected behaviour (in that the binary works without including the SFML libs)
-
Milerius, Give this Pull request a try if you can. It should solve the issue: https://github.com/SFML/SFML/pull/1485