I am using a large code-base that compiled successfully before using make with a makefile and cmake. However, now that I'm trying to use openmp with it, I'm now getting the errors
undefined reference to `omp_get_thread_num'
undefined reference to `omp_get_num_threads'
I don't think this is a problem with tthe CMakeLists.txt file, because I created a seperate directory and successfully built and compiled a helloworld OpenMP program. So what is causing this error?
I edited the CMakeLists.txt in project/src/project so to include -fopenmp so it contains the line
set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -fopenmp")
....
TARGET_LINK_LIBRARIES(PROJECT ${OpenMP_CXX_LIBRARIES} ${PROJECT_LINK_LIBS}).
The CMakeLists.txt already has the lines
FIND_PACKAGE( OpenMP)
if(OPENMP_FOUND)
message("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()
include_directories(SYSTEM ${OpenMP_INCLUDE_PATH})
Maybe I'm a little bit late to the question. However, I've encountered the same problem recently.
It was resolved by purging the tbb package on my linux os.
The theory is that the tbb package conflicts with the OpenMP, and it won't show up at the stage of compilation.
Specifically, I removed the libtbb-dev package with
sudo apt remove libtbb-dev
as described here:
https://github.com/caiowakamatsu/CRender/blob/master/readme.md#bugsissues-with-building
If you get an error such as
./CRender: symbol lookup error: /opt/intel/oneapi/oidn/1.4.0/lib/libOpenImageDenoise.so.1: undefined symbol: _ZN3tbb6detail2r15spawnERNS0_2d14taskERNS2_18task_group_contextEyou need to remove every tbb package except the intel one. If if you get aglenableetc error you need to get new drivers If it cannot find embree you will need to go to/opt/intel/oneapiand moveembreeto a folder called embree instead ofembreeX.XXX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With