webarkit / opencv-em

A simple utility script to build OpenCV static libs with Emscripten
GNU General Public License v3.0
19 stars 3 forks source link

project wasm-ar fails to build #1

Closed kalwalt closed 1 year ago

kalwalt commented 4 years ago

@EdwardLu2018 I created a build from the script with the libs, includes and opencv.js files. It use now the python command: https://github.com/webarkit/opencv-em/blob/eb3d872a04f40b5a52884318f6a6fb4dbb0f0834/build.sh#L25 as i used already (and that was fine before) but with your latest changes i receive this error:

emmake make
make: make
Scanning dependencies of target wasm_ar
[ 50%] Building CXX object CMakeFiles/wasm_ar.dir/src/wasm_ar.cpp.o
[100%] Linking CXX executable wasm_ar.js
error: undefined symbol: _ZN2cv3MatC1ERKS0_ (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN2cv3MatC1ERKS0_ may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN2cv3MatC1EiiiPvm (referenced by top-level compiled C/C++ code)
warning: __ZN2cv3MatC1EiiiPvm may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN2cv3MatC1Ev (referenced by top-level compiled C/C++ code)
warning: __ZN2cv3MatC1Ev may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN2cv3MatD1Ev (referenced by top-level compiled C/C++ code)
warning: __ZN2cv3MatD1Ev may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZNK2cv3Mat5cloneEv (referenced by top-level compiled C/C++ code)
warning: __ZNK2cv3Mat5cloneEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZNK2cv3Mat5emptyEv (referenced by top-level compiled C/C++ code)
warning: __ZNK2cv3Mat5emptyEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '/home/walter/emsdk/node/12.18.1_64bit/bin/node /home/walter/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpof609eqg.txt' failed (1)
make[2]: *** [CMakeFiles/wasm_ar.dir/build.make:96: wasm_ar.js] Errore 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/wasm_ar.dir/all] Errore 2
make: *** [Makefile:84: all] Errore 2

i include the package in zip format opencv-em-4.5.0-beta.zip If you can test, i will appreciate it.

EdwardLu2018 commented 4 years ago

How should I be using opencv-em? Just replace opencv in my project with opencv-em?

kalwalt commented 4 years ago

Hi Edward, you should put the content of the opencv-em folder inside your opencv/build_wasm. :smile:

EdwardLu2018 commented 4 years ago

Hmm interesting. Does it still work with the normal opencv build_wasm?

kalwalt commented 4 years ago

Hmm interesting. Does it still work with the normal opencv build_wasm?

yes tried right now. no issue at all. Maybe i will re-run the build script (opencv-em) and clearing the project before re-trying... I will do tomorrow. Too late now here... Thank you for testing! :slightly_smiling_face:

EdwardLu2018 commented 4 years ago

Yeah, no problem! For some weird reason when I cloned this repo in an opencv directory, rebuilt it, and changed my CMakeLists.txt to include opencv/opencv-em/packaging/opencv-em instead of opencv/build_wasm it seemed to compile fine. Changing to opencv/opencv-em/build_wasm instead of opencv/build_wasm also compiled fine. I don't have too much time to check why today, but it possibly might be that you just have to rebuild opencv-em? I'm pretty sure any recent changes I made to wasm-ar would not have caused undefined symbols in compilation, especially not _ZN2cv3MatC1ERKS0_, which I think is just a mangled name for the opencv Mat class.

kalwalt commented 4 years ago

Thank you @EdwardLu2018! it might be possible, i will re-try this evening.

kalwalt commented 4 years ago

I need also to change, in the build script, the rsync section for the modules, they are some not needed includes and other missed...

kalwalt commented 4 years ago

My fault!! :open_mouth: :sob: Because the opencv version that i cloned inside wasm-ar was aligned to the master branch, instead opencv-em is aligned to the 4.5.0 tag (version) so i was getting that error of course! I made some little changes in the build script and soon i will release a beta version of the built package. :partying_face: I think that will work also the script version with cmake commands not only the python...

kalwalt commented 4 years ago

beta release: https://github.com/webarkit/opencv-em/releases/download/0.0.1/opencv-em-4.5.0-beta.zip

EdwardLu2018 commented 4 years ago

Great to hear!

kalwalt commented 4 years ago

I have made some changes to the build script: added Usage intro and the possibility to choose which type of building process (python or cmake) it works both, but with cmake i was able only to build the static libs. It's enough since it is not required opencv.js. Now all the build files are wrapped inside a build_wasm folder instead of opencv-em. You need only to unzip it inside the opencv folder and that's it. New release is coming!

kalwalt commented 4 years ago

new release here: https://github.com/webarkit/opencv-em/releases/tag/0.0.2

kalwalt commented 4 years ago

You can try also this gist run these commands inside wasm-ar main folder. :slightly_smiling_face:

EdwardLu2018 commented 4 years ago

I think I still need the opencv.hpp file from opencv/include/opencv2, no?

kalwalt commented 4 years ago

The .zip packed all needed, think you should change your include path.

EdwardLu2018 commented 4 years ago

I still can't get it to compile without including the opencv.hpp file. When I copy opencv/include (which has the opencv.hpp file) from the main opencv repo into the unzipped build_wasm folder from the opencv-em release, it builds fine with some changes to include path in my CMakeLists.txt, but I can't get it to compile without including that file. I also don't see that file in the opencv-em release. Am I just missing something?

kalwalt commented 4 years ago

Edward i will check again when i have a bit of time. 😉🙂 And thank you for testing!!

kalwalt commented 4 years ago

I still can't get it to compile without including the opencv.hpp file. When I copy opencv/include (which has the opencv.hpp file) from the main opencv repo into the unzipped build_wasm folder from the opencv-em release, it builds fine with some changes to include path in my CMakeLists.txt, but I can't get it to compile without including that file. I also don't see that file in the opencv-em release. Am I just missing something?

@EdwardLu2018 you are right, i will update the opencv-em script to include opencv.hpp in the zip file. It needs also to change the gist, to copy the opencv2/opencv.hpp file in opencv/include directory if not present.

EDIT: the gist script should also copy the include modules...

kalwalt commented 4 years ago

New release here: https://github.com/webarkit/opencv-em/releases/tag/0.0.3 try the updated gist It should be fine now. :slightly_smiling_face:

EdwardLu2018 commented 4 years ago

Awesome! It works fine (with some changes to build.sh)!

kalwalt commented 4 years ago

If you have used/tested the gist, the script copy the files in the required destination. See my comments. I will think what is better....

kalwalt commented 1 year ago

Now opencv-em is mainly focused on serving as base for our project WebARKitLib and WebARKit so i'm not sure that will works alos for wasm-ar, probably is needed some modifications to the script or maybe some opencv libs is not needed anymore to wasm-ar. Closing because it is an outdated issue.