Building webassembly with opencv - c++

I've been trying to build a piece of code in webassembly that would use OpenCV.
I took https://github.com/mpizenberg/emscripten-opencv to start building, this worked well, but when I try adding cv::resize to be able to resize an image, that's when I have some issues:
make[1]: Entering directory '/code/build'
make[2]: Entering directory '/code/build'
make[3]: Entering directory '/code/build'
Scanning dependencies of target hello
make[3]: Leaving directory '/code/build'
make[3]: Entering directory '/code/build'
[ 50%] Building CXX object CMakeFiles/hello.dir/source/main.cpp.o
[100%] Linking CXX executable hello.js
error: undefined symbol: _Z7cvFloorRKN2cv10softdoubleE
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: _Z7cvRoundRKN2cv10softdoubleE
error: undefined symbol: _Z9cvRound64RKN2cv10softdoubleE
error: undefined symbol: _ZN2cv10softdoubleC1Ei
error: undefined symbol: _ZN2cv10softdoubleC1Ex
error: undefined symbol: _ZNK2cv10softdoubledvERKS0_
error: undefined symbol: _ZNK2cv10softdoublemiERKS0_
error: undefined symbol: _ZNK2cv10softdoublemlERKS0_
error: undefined symbol: _ZNK2cv10softdoubleplERKS0_
Error: Aborting compilation due to previous errors
shared:ERROR: '/emsdk_portable/node/bin/node /emsdk_portable/sdk/src/compiler.js /tmp/tmpS6bxjF.txt /emsdk_portable/sdk/src/embind/emval.js /emsdk_portable/sdk/src/embind/embind.js /emsdk_portable/sdk/src/library_pthread_stub.js' failed (1)
CMakeFiles/hello.dir/build.make:95: recipe for target 'hello.js' failed
make[3]: *** [hello.js] Error 1
make[3]: Leaving directory '/code/build'
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/hello.dir/all' failed
make[2]: *** [CMakeFiles/hello.dir/all] Error 2
make[2]: Leaving directory '/code/build'
Makefile:83: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/code/build'
Makefile:5: recipe for target 'build' failed
make: *** [build] Error 2
The command '/bin/sh -c make build' returned a non-zero code: 2
make: *** [all] Error 2
I tried wrapping up my problem here https://github.com/jdrouet/opencv-wasm, you can pull it and run make, it'll build with docker.
Do you have any idea of how I could fix my issue?

Ok, looks like I found a way to build it (still here https://github.com/jdrouet/opencv-wasm) but now, when I try to use the resize function, I end up with the following error :
Error: the string "174007712 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch." was thrown, throw an Error :)
So now, I don't know if I'm not using the function well... Here is the function : https://github.com/jdrouet/opencv-wasm/blob/master/source/resizer.cpp#L23
Do you have any idea of why it's not working?

Related

undefined reference to `omp_get_wtime'

i learn c++, OpenMP. I have tried compile my program with omp_get_wtime and it doesn't work, but when i deleted this, it works. i must add something, but what and where. In openmptryflags or Cmakelists?
snap/clion/61/bin/cmake/linux/bin/cmake --build /home/bapah/CLionProjects/omp1/cmake-build-debug --target omp1 -- -j 6
[ 50%] Linking CXX executable omp1
CMakeFiles/omp1.dir/main.cpp.o: In function `main':
/home/bapah/CLionProjects/omp1/main.cpp:36: undefined reference to `omp_get_wtime'
collect2: error: ld returned 1 exit status
CMakeFiles/omp1.dir/build.make:83: recipe for target 'omp1' failed
make[3]: *** [omp1] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/omp1.dir/all' failed
make[2]: *** [CMakeFiles/omp1.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/omp1.dir/rule' failed
make[1]: *** [CMakeFiles/omp1.dir/rule] Error 2
Makefile:118: recipe for target 'omp1' failed
make: *** [omp1] Error 2
Solution :
add to CMakeList.txt
SET_TARGET_PROPERTIES(omp1 PROPERTIES COMPILE_FLAGS "-fopenmp"
LINK_FLAGS "-fopenmp")
P.s. omp1 - name your project.
P.p.s. also you can write target_link_libraries(omp1 -fopenmp)

open cv install not working properly

when i am doing make in /opencv/build directory it is working upto some extent after that it is showing this kind of error what should i do
Linking CXX executable ../../bin/opencv_test_core
CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o: file not
recognized:
File truncated collect2: error: ld returned 1 exit status modules/core
/CMakeFiles/opencv_test_core.dir/build.make:824: recipe for target 'bin/opencv_test_core' failed make[2]: * [bin/opencv_test_core]
Error 1 CMakeFiles/Makefile2:1421: recipe for target
'modules/core/CMakeFiles/opencv_test_core.dir/all' failed make[1]: *
[modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2
Makefile:147: recipe for target 'all' failed make: *** [all] Error 2
Your problem is most likely here:
CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o: file not recognized: File truncated
Delete the object (.o) file and rerun. The make call was probably interrupted before which caused the object file to be truncated.

Undefined reference when compiling library with clang

I'm trying to build the libdepixelize library , but I'm getting the following error:
[100%] Linking CXX executable depixelize-kopf2011
/usr/bin/ld: /usr/local/lib/lib2geom.a(nearest-point.o): undefined reference to symbol '_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv##GLIBCXX_3.4.21'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/build.make:95: recipe for target 'src/depixelize-kopf2011/depixelize-kopf2011' failed
make[2]: *** [src/depixelize-kopf2011/depixelize-kopf2011] Error 1
CMakeFiles/Makefile2:142: recipe for target 'src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/all' failed
make[1]: *** [src/depixelize-kopf2011/CMakeFiles/depixelize-kopf2011.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
I'm using clang with libstdc++ as compiler. GCC didn't work either.
EDIT: I used this in the CMakeLists file: set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") and then did cmake -DCMAKE_CXX_COMPILER="clang++" .. and make to compile it. The full log is here: https://hastebin.com/axasololuc.js
I have no idea what exactly it means, or even how to fix it.

Compile error when trying to install gst-plugins-bad 1.4.3

I am trying to install gst-plugins-bad 1.4.3 in order to install gstreamer-sharp 1.39 in order to install banshee 2.9.1. I downloaded the source distribution from git and was able to run autogen.sh, but running make install crashes with the following error.
make[3]: Leaving directory `/home/david/Downloads/gst-plugins-bad/gst'
make[2]: Leaving directory `/home/david/Downloads/gst-plugins-bad/gst'
make[1]: Leaving directory `/home/david/Downloads/gst-plugins-bad/gst'
Making install in sys
make[1]: Entering directory `/home/david/Downloads/gst-plugins-bad/sys'
Making install in decklink
make[2]: Entering directory `/home/david/Downloads/gst-plugins-bad/sys/decklink'
CXXLD libgstdecklink.la
/usr/bin/ld: .libs/libgstdecklink_la-gstdecklink.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
.libs/libgstdecklink_la-gstdecklink.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libgstdecklink.la] Error 1
make[2]: Leaving directory `/home/david/Downloads/gst-plugins-bad/sys/decklink'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/david/Downloads/gst-plugins-bad/sys'
make: *** [install-recursive] Error 1
I don't know how to respond to this error and I can't seem to find anyone else who has encountered it. What should I do? I am running Linux Mint 13.

make "sumo 0.17.1" on ubuntu 13.10

I installed and tested v0.19.1 successfully before, however, I needed to downgrade to 0.17.1 in order to run some example in omnetpp's veins simulator.
Whenever I run the "make" command, I get the following error:
/usr/bin/ld: ./utils/foxtools/libfoxtools.a(MFXMutex.o): undefined reference to symbol 'pthread_mutexattr_settype##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [sumo-gui] Error 1
make[3]: Leaving directory `/home/maamoun/pkgs/sumo-0.17.1/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/maamoun/pkgs/sumo-0.17.1/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/maamoun/pkgs/sumo-0.17.1/src'
make: *** [all-recursive] Error 1
What am I missing?!
Problem solved, had to install libproj-dev and include proj in the ./configure using the --with-proj-includes=DIR
[EDIT] after 15 minutes of making, same error raised again!!!