Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

SFML 3: Static libraries on Android #3533

@Zombieschannel

Description

@Zombieschannel

Prerequisite Checklist

Describe your feature request here

I was looking a bit as to why SFML on Android seems to be locked to using shared libraries.
It seems to be like this from the very start and currently CMakeLists has these few not very explained lines:

# disable static libraries on Android
if(SFML_OS_ANDROID)
    set(BUILD_SHARED_LIBS ON)
endif()

From what I've gathered it may have been related to the fact that SFML 2 uses openal which has to be a shared library due to the licence or something OpenGL context related.

Since SFML 3 does not have sfml-activity anymore - and older Android devices require it - these devices cannot work with SFML 3 so static libraries could possibly allow it to work.
I am aware rarely anyone is still using Android 5 and below these days and I'm not even sure it could work with C++17, but it could be worth a try.

I've tested what happens if BUILD_SHARED_LIBS is OFF, and SFML actually seems to compile and install just fine, something with CMake is wrong though since when trying to link SFML statically to a project this happens:

C/C++: CMake Error at /home/zombie/Android/Sdk/ndk/27.2.12479018/sources/third_party/sfml/lib/arm64-v8a/cmake/SFML/SFMLWindowStaticTargets.cmake:62 (set_target_properties):
C/C++:   The link interface of target "SFML::Window" contains:
C/C++:     EGL::EGL
C/C++:   but the target was not found.  Possible reasons include:
C/C++:     * There is a typo in the target name.
C/C++:     * A find_package call is missing for an IMPORTED target.
C/C++:     * An ALIAS target is missing.

I haven't had time to see what goes wrong here but likely someone who knows what they're doing in the CMake land could fix this relatively quickly.

Use Cases

Older Android devices could potentially get newest SFML features.

API Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions