Godot Version
4.2.2
Question
I’m trying to build a godot extension that uses modules from OpenCV. Within my application folder I have the godot-cpp folder, a src folder containing the code for my extension node as well as register_types.cpp and register_types.h, an include folder which has an opencv2 subfolder that contains all of the opencv headers, and a lib folder that holds opencv_world490.dll and opencv_world490.lib.
I am encountering the error “fatal error C1083: Cannot open include file: ‘opencv2/core/mat.hpp’: No such file or directory” which makes me think scons is not recognizing the opencv headers even though I have listed the folder in the CPPPATH. I found the following post which seems like its trying to do something similar and added those lines to my scon file which is in the root directory.
https://www.reddit.com/r/godot/comments/1deoxn2/how_to_link_a_godot_extension_with_a_precompiled/
Here is my Scon File:
import os
import sys
env = SConscript("godot-cpp/SConstruct")
env.Append(CPPPATH=["src/", "include/"])
env.Append(LIBS=["opencv_world490"])
env.Append(LIBPATH=["lib/"])
sources = Glob("src/*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"demoproject/bin/CalibratedCamera.{}.{}.framework/CalibratedCamera.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demoproject/bin/CalibratedCamera{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)
And my file structure with the include headers: