I have a problem using threads in my application. I am writing C++ files, that are used in Android, so they are compiled with NDK and cmake. I have no idea how to load thread support. Is there anything i have to write into CMakeLists or the MakeFile or something like that? I am an absolute beginner in writing C++ code...
If you are using Cmake for Android, eg https://github.com/taka-no-me/android-cmake , then to enable std::thread
you should specify
ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8
and
ANDROID_STL=gnustl_static
(or gnustl_shared
),
To enable C++11 thread class ( std::thread
) with Cmake simply add to your CMakeLists.txt
the following line:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror")
Full example here .
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.