Configure OpenMP for all platforms

Configure OpenMP for all platforms
0

#1

Does someone setup OpenMP for Android/iOS (or desktop with cmake) and can give some advices, what to do, that it will run correct? My naiv way was (insert in the CMakeLists.txt):

find_package(OpenMP)
if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

but it doesn’t compile in CLion:

Undefined symbols for architecture x86_64:
  "___kmpc_critical", referenced from:
      _.omp_outlined._debug__ in MyClass.cpp.o
  "___kmpc_end_critical", referenced from:
      _.omp_outlined._debug__ in MyClass.cpp.o
  "___kmpc_fork_call", referenced from:
      namespace::MyClass::func() in MyClass.cpp.o
  "_omp_get_thread_num", referenced from:
      _.omp_outlined._debug__ in MyClass.cpp.o
ld: symbol(s) not found for architecture x86_64

I want to use it for some calculations, so it can use multithreading the easy way.

PS: Maybe the cocos team can preconfigure it in v4 (or someone is willing to create a PR with it).


#2

I use on Linux. Not sure if I can help.