简体   繁体   中英

SDL2 in Android library

I'm currently trying to add SDL2 library in a Android library.

Android project is managed only with a CMakeList.txt file (no Android.mk)

I'm not able to make it compile. It's a basic C++ android gradle project, in the CMakeList.txt I added the line:

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/AAA/third_party/SDL2")

But I'm getting linker error like

fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
       ^~~~~~~~~~~~
1 error generated.

Someone can explain me how can I add SDL2 to an existing CMakelist.txt for an android project?

You need to set the includes in the CMakeLists.txt as well

# per target include
target_include_directories(your_target public "${CMAKE_CURRENT_SOURCE_DIR}/AAA/third_party/")
# globally
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/AAA/third_party/")

pd: I omitted the SDL2 in the path since you seem to include the headers as <SDL2/XXX.h> if you want to include the headers directly <XXX.h> add SDL2 to the paths ie:

target_include_directories(your_target public "${CMAKE_CURRENT_SOURCE_DIR}/AAA/third_party/SDL2")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM