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})
Although if I type
cmake ..
, I see the output
OPENMP FOUND
, I don't see
fopenmp
in any of the makefiles and I didn't see
CXXFLAGS
OR
LDFLAGS
in any of the makefiles.