Issues with crosscompiling opencvsharp: "Error adding symbols; File in wrong format" for .so files

I am having this problem when trying to cross compile opencvsharp after successfully building and making opencv (for linux-arm64). I cmake opencvsharp with no problems but when I make I get this “Error adding Symbols; File in wrong format” error:

Scanning dependencies of target OpenCvSharpExtern
[  2%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/bgsegm.cpp.o
[  8%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/aruco.cpp.o
[  8%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/calib3d.cpp.o
[ 11%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/core.cpp.o
[ 14%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/flann.cpp.o
[ 17%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/dnn.cpp.o
[ 20%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/img_hash.cpp.o
[ 23%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/cuda.cpp.o
[ 26%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/line_descriptor.cpp.o
[ 29%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/imgcodecs.cpp.o
[ 32%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/ml.cpp.o
[ 35%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/features2d.cpp.o
[ 38%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/dnn_superres.cpp.o
[ 41%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/quality.cpp.o
[ 44%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/tracking.cpp.o
[ 50%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/xfeatures2d.cpp.o
[ 55%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/highgui.cpp.o
[ 50%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/imgproc.cpp.o
[ 52%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/ximgproc.cpp.o
[ 61%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/text.cpp.o
[ 64%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/stitching.cpp.o
[ 67%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/wechat_qrcode.cpp.o
[ 67%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/video.cpp.o
[ 73%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/objdetect.cpp.o
[ 73%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/xphoto.cpp.o
[ 76%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/std_string.cpp.o
[ 82%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/shape.cpp.o
[ 79%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/videoio.cpp.o
[ 97%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/face.cpp.o
[ 97%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/optflow.cpp.o
[ 85%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/photo.cpp.o
[ 97%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/std_vector.cpp.o
[ 88%] Building CXX object OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/superres.cpp.o
[100%] Linking CXX shared library libOpenCvSharpExtern.so
/media/data/[CENSORED]/dotnet/lib/opencv/opencv/platforms/linux/build/lib/libopencv_gapi.so.4.7.0: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/build.make:978: recipe for target 'OpenCvSharpExtern/libOpenCvSharpExtern.so' failed
make[2]: *** [OpenCvSharpExtern/libOpenCvSharpExtern.so] Error 1
CMakeFiles/Makefile2:85: recipe for target 'OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/all' failed
make[1]: *** [OpenCvSharpExtern/CMakeFiles/OpenCvSharpExtern.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Error adding Symbols; File in wrong format

for libopencv_gapi.so.4.7.0

and I built fresh from master branches of opencv, opencv_contrib and opencvsharp… please help

that’s not “the same problem” though. I’ve split your post off into a new thread.

“opencvsharp” is a separate project unrelated to OpenCV. you should contact the maintainers of that project.

1 Like

when doing major changes to the build process, as changing target-arch or cc-chain, – clean the build folder ! (and start all over with cmake)

I followed this practice, it does not fix the problem unfortunately.