zanazakaryaie / ARM-VO

Efficient monocular visual odometry for ground vehicles on ARM processors
MIT License
241 stars 68 forks source link

Could NOT find OpenMP_CXX #10

Open bot-lin opened 2 years ago

bot-lin commented 2 years ago

Laptop: Macbook Air M2 OS: Ubuntu 20.04 Docker

When I was runing cmake . , I got following error

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.5.0")
-- Found OpenMP_C: -fopenmp (found version "4.5")
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenMP.cmake:511 (find_package_handle_standard_args)
  CMakeLists.txt:13 (find_package)

-- Configuring incomplete, errors occurred!
See also "/ARM-VO/CMakeFiles/CMakeOutput.log".
See also "/ARM-VO/CMakeFiles/CMakeError.log".

Has anyone experienced this?

Thanks

zanazakaryaie commented 2 years ago

Hi @bot-lin Finding and linking OpenMP on Mac devices sometimes becomes tricky. Can you add these lines to the cmake file and run it again?

if(NOT TARGET OpenMP::OpenMP_CXX)
    add_library(OpenMP_TARGET INTERFACE)
    add_library(OpenMP::OpenMP_CXX ALIAS OpenMP_TARGET)
    target_compile_options(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
    find_package(Threads REQUIRED)
    target_link_libraries(OpenMP_TARGET INTERFACE Threads::Threads)
    target_link_libraries(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
endif()
bot-lin commented 2 years ago

Hi, @zanazakaryaie Thaks for your reply.

I have added the line to the cmake file and this is how my cmake file looks like

cmake_minimum_required(VERSION 2.8)

project(ARM_VO)

SET(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -O3 -std=c++11 -mfpu=neon -mfloat-abi=hard -funroll-loops -Ofast")

find_package(OpenCV REQUIRED)
if(NOT OpenCV_FOUND)
    message(FATAL_ERROR "OpenCV not found.")
endif()

if(NOT TARGET OpenMP::OpenMP_CXX)
    add_library(OpenMP_TARGET INTERFACE)
    add_library(OpenMP::OpenMP_CXX ALIAS OpenMP_TARGET)
    target_compile_options(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
    find_package(Threads REQUIRED)
    target_link_libraries(OpenMP_TARGET INTERFACE Threads::Threads)
    target_link_libraries(OpenMP_TARGET INTERFACE ${OpenMP_CXX_FLAGS})
endif()

find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
else()
    message(WARNING "OpenMP not found.")
endif()

include_directories(include)

file(GLOB SOURCES "src/*.cpp")
add_executable(ARM_VO ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

Anf the cmake output is as following:

zl@zl-Parallels-ARM-Virtual-Machine:~/ARM-VO$ cmake .
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.5.0") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found OpenMP_C: -fopenmp (found version "4.5") 
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenMP.cmake:511 (find_package_handle_standard_args)
  CMakeLists.txt:23 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/zl/ARM-VO/CMakeFiles/CMakeOutput.log".
See also "/home/zl/ARM-VO/CMakeFiles/CMakeError.log".
liaohuanxuan commented 1 year ago

@bot-lin Hi I have the same problem, have you solved this problem?

bot-lin commented 1 year ago

@liaohuanxuan I am afraid not. I have also tried it on Orange Pi with a 64bit debian OS but got the same issue.

Hohyeong commented 8 months ago

@bot-lin @liaohuanxuan Hi, I was able to successfully configure cmake on a Raspberry Pi 4B model using the Bullseye OS by modifying CMakeLists.txt:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -mfpu=neon -mfloat-abi=hard -funroll-loops -Ofast")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -funroll-loops -Ofast")

JasonWang9805 commented 2 months ago

嗨,我能够通过修改 Bullseye OS 在 Raspberry Pi 4B 模型上成功配置 cmake CMakeLists.txt:

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -O3 -std=c++11 -mfpu=neon -mfloat-abi=hard -funroll-loops -Ofast”) set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -O3 -std=c++11 -funroll-loops -Ofast”)

Thanks! I had a successful build based on your methodology on an nvidia device