Open LouieLumi opened 9 months ago
arm mac => linux amd64
I'm facing a similar issue, but when doing Linux host (WSL) with Windows target
Operating System and version: Ubuntu 22.04.4 LTS (WSL2)
OpenCV version used: 4.8.1
How did you install OpenCV?: Through package manager apt
GoCV version used: 0.35.0
Go version: 1.22.1 linux/amd64
I have the relevant mingw64 package installed for cross-compiling. This is the command I'm using: CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o bin/my_file.exe my_file
This is the output I get:
# gocv.io/x/gocv
In file included from aruco.cpp:1:
aruco.h:5:10: fatal error: opencv2/opencv.hpp: No such file or directory
5 | #include <opencv2/opencv.hpp>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Not sure how to include the relevant opencv files in the build. In my case the opencv files that is not getting imported correctly are located in /usr/include/opencv4/opencv2
I updated the build command to use CGO_CPPFLAGS="-I/usr/local/include/opencv4"
but now I get this error:
# gocv.io/x/gocv
In file included from /usr/local/include/opencv4/opencv2/core.hpp:3370,
from /usr/local/include/opencv4/opencv2/opencv.hpp:52,
from aruco.h:5,
from aruco.cpp:1:
/usr/local/include/opencv4/opencv2/core/utility.hpp:718:14: error: ‘recursive_mutex’ in namespace ‘std’ does not name a type
718 | typedef std::recursive_mutex Mutex;
| ^~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/utility.hpp:63:1: note: ‘std::recursive_mutex’ is defined in header ‘<mutex>’; did you forget to ‘#include <mutex>’?
62 | #include <mutex> // std::mutex, std::lock_guard
+++ |+#include <mutex>
63 | #endif
/usr/local/include/opencv4/opencv2/core/utility.hpp:719:29: error: ‘Mutex’ is not a member of ‘cv’
719 | typedef std::lock_guard<cv::Mutex> AutoLock;
| ^~~~~
/usr/local/include/opencv4/opencv2/core/utility.hpp:719:29: error: ‘Mutex’ is not a member of ‘cv’
/usr/local/include/opencv4/opencv2/core/utility.hpp:719:34: error: template argument 1 is invalid
719 | typedef std::lock_guard<cv::Mutex> AutoLock;
| ^
In file included from /usr/local/include/opencv4/opencv2/flann/kdtree_index.h:44,
from /usr/local/include/opencv4/opencv2/flann/all_indices.h:38,
from /usr/local/include/opencv4/opencv2/flann/flann_base.hpp:44,
from /usr/local/include/opencv4/opencv2/flann.hpp:48,
from /usr/local/include/opencv4/opencv2/opencv.hpp:65,
from aruco.h:5,
from aruco.cpp:1:
/usr/local/include/opencv4/opencv2/flann/heap.h: In static member function ‘static cv::Ptr<cvflann::Heap<T> > cvflann::Heap<T>::getPooledInstance(const HashableT&, int, int)’:
/usr/local/include/opencv4/opencv2/flann/heap.h:191:20: error: ‘Mutex’ in namespace ‘cv’ does not name a type
191 | static cv::Mutex mutex;
| ^~~~~
/usr/local/include/opencv4/opencv2/flann/heap.h:192:33: error: ‘mutex’ was not declared in this scope
192 | const cv::AutoLock lock(mutex);
| ^~~~~
Actually I ended up solving the issues I mentioend through two things:
$ sudo update-alternatives --config i686-w64-mingw32-gcc
<choose i686-w64-mingw32-gcc-posix from the list>
$ sudo update-alternatives --config i686-w64-mingw32-g++ <choose i686-w64-mingw32-g++-posix from the list>
$ sudo update-alternatives --config x86_64-w64-mingw32-gcc
Description
Steps to Reproduce
Your Environment
env.sh
orenv.cmd
script before trying togo run
orgo build
?