Building opencv using Emscripten

I am trying to build using Emscripten using…
cmake -DCMAKE_TOOLCHAIN_FILE=/Users/arvindarya/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=…/libs
-DBUILD_SHARED_LIBS=OFF
-DOPENCV_EXTRA_MODULES_PATH=/Users/arvindarya/opencv_contrib/modules
-DBUILD_opencv_contrib_world=ON
-DENABLE_PRECOMPILED_HEADERS=OFF
-D__TBB_machine_fetchadd4=__sync_fetch_and_add

I am getting an error

/Users/arvindarya/opencv/3rdparty/ittnotify/src/ittnotify/ittnotify_config.h:377:12: error: call to undeclared function ‘__TBB_machine_fetchadd4’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return __TBB_machine_fetchadd4(ptr, 1) + 1L;
^

NO matter how I make it can anyone tell me how to get rid of this error.

Thank You SO Much
I have tried…
emcmake cmake -DCMAKE_TOOLCHAIN_FILE=/Users/arvindarya/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DOPENCV_GENERATE_PKGCONFIG=ON
-DENABLE_NEON=OFF -DENABLE_VFPV3=OFF -DENABLE_SSE=OFF -DENABLE_SSE2=OFF
-DENABLE_SSE3=OFF -DENABLE_SSSE3=OFF -DENABLE_SSE41=OFF -DENABLE_SSE42=OFF
-DWITH_TBB=ON -DWITH_OPENMP=OFF -DWITH_CUDA=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF
-DOPENCV_EXTRA_MODULES_PATH=/Users/arvindarya/opencv_contrib/modules
-DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF
-DCMAKE_C_FLAGS=“-std=c99”
-DCMAKE_CXX_FLAGS=“-std=c++11”
emcmake cmake -DCMAKE_TOOLCHAIN_FILE=/Users/arvindarya/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DOPENCV_GENERATE_PKGCONFIG=ON
-DENABLE_NEON=OFF -DENABLE_VFPV3=OFF -DENABLE_SSE=OFF -DENABLE_SSE2=OFF
-DENABLE_SSE3=OFF -DENABLE_SSSE3=OFF -DENABLE_SSE41=OFF -DENABLE_SSE42=OFF
-DWITH_TBB=ON -DWITH_OPENMP=OFF -DWITH_CUDA=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF
-DOPENCV_EXTRA_MODULES_PATH=/Users/arvindarya/opencv_contrib/modules
-DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF
-DCMAKE_C_FLAGS=“-std=c99”
-DCMAKE_CXX_FLAGS=“-std=c++11”

ChatGPT says you have to link tbb which I cannot do it is not happening on my Mac.
Nothing works.

i reverted your edit, this post is entirely useless without details

I think it TBB is not supported by Emscripten yet. If it can help you can look at our repo opencv-em to build the Opencv libs. In details look at the build.sh script, it has two option build with python or with cmake. You can try by yourself cloning the repository and test the build script. The script should work with OpenCV 4.5.0 and emsdk 3.1.26.