1

I am building a python extension from c++ shared library. This library is using some openmp pragma.

I would like to know how to configure CMakeLists.txt in order to include openmp ? I have added the openmp flag -fopenmp But I still have this error : undefined symbol: GOMP_critical_end

here is my CMakeLists.txt file

cmake_minimum_required(VERSION 3.10)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++lastest -pthread -fopenmp") 

project (py_interface)

#find_library('gomp')
find_package(OpenMP REQUIRED)
find_package(Boost REQUIRED) 

include_directories(/usr/include/python3.6/)

link_directories(/usr/local/lib)

set(SRC interface.cpp)

add_library(py_interface SHARED ${SRC})

target_link_libraries(py_interface PRIVATE OpenMP::OpenMP_CXX ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})

set_property(TARGET py_interface PROPERTY POSITION_INDEPENDENT_CODE ON)
einpoklum
  • 118,144
  • 57
  • 340
  • 684
rize
  • 49
  • 6
  • Does changing the `target_link_libraries` call to `target_link_libraries(py_interface PRIVATE ${PYTHON_LIBRARIES} ${Boost_LIBRARIES} OpenMP::OpenMP_CXX) ` fix the problem? – ComicSansMS Mar 23 '20 at 08:43
  • Are there multiple compilers on your system? Maybe the program is compiled with one compiler but linked to another compiler's OpenMP library. `ldd` on your compiled binary will show which library you are linking against. – RoastDuck Jul 01 '22 at 03:08
  • Does this answer your question? [How to set linker flags for OpenMP in CMake's try\_compile function](https://stackoverflow.com/questions/12399422/how-to-set-linker-flags-for-openmp-in-cmakes-try-compile-function) – Anton K Sep 13 '22 at 06:47

0 Answers0