Error:(6, 10) fatal error: 'opencv2/opencv.hpp' file not found

asked 2017-11-22 02:35:59 -0600

namacos gravatar image

updated 2017-11-22 05:03:01 -0600

I know that there are many threads that have some solution for this problem but I did not managed to resolve my issue with non of them.

I spent like a few days already on this compile error and still no success.

I use Android Studio and opencv 3.3.1

I got opencv .a files placed under jniLibs. I got .h file under jni with heder like this

#include "opencv2/opencv.hpp"

If I remove that include everything builds and I am also able to call cpp methods from java via JNI. But when it comes to this include it seems like something is not connected correctly

inside my CMakeLists.txt i have this

cmake_minimum_required(VERSION 3.4.0)

set(OpenCV_DIR /usr/local/Cellar/opencv/3.3.1_1/share/OpenCV)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)

include_directories(
    ${CMAKE_SOURCE_DIR}/include
    /usr/local/Cellar/opencv/3.3.1_1/ )

find_package( OpenCV REQUIRED )

My biggest problem I this moment is I do not know how to locate the problem :(. I do not know if my CMakeList.txt is wrong, or build.gradle or what else... Please help me find the problem

When I build with android studio all I got is line

Error:(6, 10) fatal error: 'opencv2/opencv.hpp' file not found

Thanks

edit1: for the SET(OpenCV_DIR "D:/libs/opencv-3.3/build/") comment

I am on Mac not on windows so my paths i little different I got

/usr/local/Cellar/opencv/3.3.1_1

and inside this path I got

INSTALL_RECEIPT.json LICENSE              README.md            bin                  include              lib                  share

but not build

edit retag flag offensive close merge delete

Comments

Hi I'm not 100% sure but in my cmake files under Windows I have added the following lines:

set(OpenCV_STATIC OFF)
FIND_PACKAGE(OpenCV REQUIRED)
IF(NOT OpenCV_FOUND)
    MESSAGE(FATAL_ERROR "OpenCV not found.")
ENDIF(NOT OpenCV_FOUND)
set_target_properties(${OpenCV_LIBS} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)

include_directories(
    ${OpenCV_INCLUDE_DIRS}
)

link_directories(
    ${OpenCV_LIB_DIR}
)

#now adding ALL opencv dlls
FILE(GLOB opencv_dlls "${OpenCV_DIR}/x64/vc15/bin/*.dll")


install(FILES 
${opencv_dlls}
)
VxW gravatar imageVxW ( 2017-11-22 02:58:31 -0600 )edit

hi, @namacos, there were 10 duplicates of your question here !

it's probably not your fault, seems to happen while ppl are in the moderation queue.

however, if you recall anything, that led to this, like a flaw in the website, please let us know !

berak gravatar imageberak ( 2017-11-22 03:04:02 -0600 )edit

where is your OpenCV_DIR defined ?

namacos gravatar imagenamacos ( 2017-11-22 03:09:33 -0600 )edit

my OpenCV_Dir is

SET(OpenCV_DIR "D:/libs/opencv-3.3/build/")
VxW gravatar imageVxW ( 2017-11-22 04:55:22 -0600 )edit

I know I should nod duplicate things, but to be honest non of the previous duplicates solves my problem. I tried everything. I seems like a common problem for some miss-configuration but there is no obvious solution to this (at least not for beginners like me).

namacos gravatar imagenamacos ( 2017-11-22 04:56:47 -0600 )edit

@VxW please see my edit, thanks

namacos gravatar imagenamacos ( 2017-11-22 05:03:31 -0600 )edit

I'm not familar with Mac but what happens if you set your OpenCV_Dir to the location where your OpenCV cmake file is located?

VxW gravatar imageVxW ( 2017-11-22 05:09:54 -0600 )edit
namacos gravatar imagenamacos ( 2017-11-23 06:51:11 -0600 )edit