I built my opencv libraries for WebAssembly and have a simple program,My 
*Program*:
#include"opencv2/opencv.hpp"
#include<iostream>
#include<emscripten.h>

using namespace std;
using namespace cv;

int main(){
cout<<"Let's see\n";
uint8_t uarr[] = {1,2,3,4,5,6,7,8,9,10,11,12};
int rows=2;
int cols=2;
Mat mat1(rows,cols,CV_8UC3, uarr);

cout<<"Put oil in the car: "<<mat1<<"\n"; 
return 1;
}

My *CMakeLists.txt:*

cmake_minimum_required( VERSION 3.1 )
set( CMAKE_CXX_STANDARD 11 )
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
project( HelloCV )

# Does not work
# find_package( OpenCV REQUIRED PATHS third-party/opencv-4.1.0/build_wasm 
NO_DEFAULT_PATH)

# Needed for opencv2/opencv.hpp
include_directories( /Users/arvindarya/Desktop/aspen/opencv/include )

# Needed by opencv.hpp for opencv2/opencv_modules.hpp
include_directories( /Users/arvindarya/Desktop/aspen/opencv/build_wasm )

# Needed by opencv_modules.hpp for every module
file( GLOB opencv_include_modules 
"/Users/arvindarya/Desktop/aspen/opencv/modules/*/include" )
include_directories( ${opencv_include_modules} )

# Our hello world executable
add_executable( hello image.cpp )

# Link to opencv.js precompiled libraries
file( GLOB opencv_js 
"/Users/arvindarya/Desktop/aspen/opencv/build_wasm/lib/*.a" )
target_link_libraries( hello ${opencv_js} )


I am running
*emmake cmake *. 

and
*make *

I am getting an *error*:

clang-14: warning: argument unused during compilation: 
'-mmacosx-version-min=10.15' [-Wunused-command-line-argument]

In file included from /Users/arvindarya/Desktop/aspen/image.cpp:3:

In file included from 
/Users/arvindarya/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/iostream:37:

In file included from 
/Users/arvindarya/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/ios:215:

/Users/arvindarya/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__locale:40:11:
 
fatal error: 'xlocale.h' file not found

# include <xlocale.h>

          ^~~~~~~~~~~

1 error generated.

em++: error: '/Users/arvindarya/emsdk/upstream/bin/clang++ -target 
wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions 
-fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm 
-enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=3 
-D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=0 -D_LIBCPP_ABI_VERSION=2 
-Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL 
--sysroot=/Users/arvindarya/emsdk/upstream/emscripten/cache/sysroot -Xclang 
-iwithsysroot/include/compat 
-I/Users/arvindarya/Desktop/aspen/opencv/include 
-I/Users/arvindarya/Desktop/aspen/opencv/build_wasm 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/calib3d/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/core/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/dnn/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/features2d/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/flann/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/gapi/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/highgui/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/imgcodecs/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/imgproc/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/ml/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/objdetect/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/photo/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/stitching/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/ts/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/video/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/videoio/include 
-I/Users/arvindarya/Desktop/aspen/opencv/modules/world/include -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
 
-mmacosx-version-min=10.15 -std=gnu++11 -MD -MT 
CMakeFiles/hello.dir/image.cpp.o -MF CMakeFiles/hello.dir/image.cpp.o.d -c 
/Users/arvindarya/Desktop/aspen/image.cpp -o 
CMakeFiles/hello.dir/image.cpp.o' failed (returned 1)

make[2]: *** [CMakeFiles/hello.dir/image.cpp.o] Error 1

make[1]: *** [CMakeFiles/hello.dir/all] Error 2

make: *** [all] Error 2

Can anyone help me with this.I want to run a WebAssembly with some opencv 
this is the most basic code. Is something wrong with my CMake. I cannot 
even get <iostream> work there is something seriously wrong. Please help 
me. I have tried emcc --clear-cache it does not work.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/ea0d433a-1e67-42a4-9cef-f5e1e9c2ad93n%40googlegroups.com.

Reply via email to