WebGL Sample Build Problem : undefined symbol

>emmake make install
make: make install
[ 33%] Linking CXX executable occt-webgl-sample.js
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: vtable for Graphic3d_TransformPers
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Aspect_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Wasm_Window
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: vtable for TopoDS_TShape
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: vtable for TopoDS_TCompound
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Standard_Failure
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Standard_Transient
wasm-ld: error: CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o: undefined symbol: typeinfo for Standard_Failure
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
em++: error: 'D:/Download/emsdk-main/upstream/bin\wasm-ld.exe -o occt-webgl-sample.wasm CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o CMakeFiles/occt-webgl-sample.dir/main.cpp.o -LC:/PROGRA~2/OCCT/win32/vc14/lib "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKRWMesh.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKBinXCAF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKBin.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKBinL.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKOpenGles.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKXCAF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKVCAF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKCAF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKV3d.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKHLR.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKMesh.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKService.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKShHealing.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKPrim.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKTopAlgo.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKGeomAlgo.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKBRep.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKGeomBase.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKG3d.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKG2d.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKMath.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKLCAF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKCDF.lib" "C:/Program Files (x86)/OCCT/win32/vc14/libd/TKernel.lib" D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/freetype.lib D:/Software/vcpkg/packages/zlib_x86-windows/lib/zlib.lib D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/bz2.lib D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/libpng16.lib D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/zlib.lib D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/brotlidec-static.lib D:/Software/vcpkg/packages/freetype_x86-windows-static/lib/brotlicommon-static.lib -LD:\Download\emsdk-main\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL-webgl2 -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=malloc --export=free --export=__cxa_is_pointer_type --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024' failed (returned 1)
CMakeFiles\occt-webgl-sample.dir\build.make:146: recipe for target 'occt-webgl-sample.js' failed
make[2]: *** [occt-webgl-sample.js] Error 1
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/occt-webgl-sample.dir/all' failed
make[1]: *** [CMakeFiles/occt-webgl-sample.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
make: *** [all] Error 2
emmake: error: 'make install' failed (returned 2)
Kirill Gavrilov's picture

You cannot build WebGL sample using OCCT libraries built by Visual Studio - OCCT should be built by the same Emscripten SDK as sample itself.

Lee Dongming's picture

Thanks.
So freetype/tcl are must built by Emscripten?
:(
a little difficult...

Lee Dongming's picture

Help!
How to build tcl/tk with cmake(by emscripten)?
It's difficult for me.
Thanks.

Lee Dongming's picture

I have solved the problem above. Thanks! New problem such as:

>emmake make install
make: C:\MinGW\bin\mingw32-make.exe install
[ 33%] Linking CXX executable occt-webgl-sample.js
wasm-ld: error: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libfreetype.a(autofit.c.o): undefined symbol: hb_ft_font_create
em++: error: 'D:/Download/emsdk-main/upstream/bin\wasm-ld.exe -o occt-webgl-sample.wasm CMakeFiles/occt-webgl-sample.dir/WasmOcctView.cpp.o CMakeFiles/occt-webgl-sample.dir/main.cpp.o -LD:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKRWMesh.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBinXCAF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBin.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBinL.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKOpenGles.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKXCAF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKVCAF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKCAF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKV3d.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKHLR.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKMesh.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKService.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKShHealing.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKPrim.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKTopAlgo.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKGeomAlgo.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBRep.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKGeomBase.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKG3d.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKG2d.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKMath.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKLCAF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKCDF.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKernel.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libfreetype.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBO.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKShHealing.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKPrim.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKTopAlgo.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKGeomAlgo.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKBRep.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKGeomBase.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKG3d.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKG2d.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKMath.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKernel.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libfreetype.a D:/Software/OpenGL_ES/libEGL.lib D:/Software/OpenGL_ES/libGLESv2.lib D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libz.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libbz2.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libpng.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libz.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libbz2.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libpng.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libharfbuzz.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libharfbuzz-subset.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libbrotlidec-static.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libbrotlicommon-static.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libbrotlienc-static.a -LD:\Download\emsdk-main\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL-webgl2 -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined-file=C:\Users\MOODLE~1\AppData\Local\Temp\1\tmp5pigoihc.undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__stdio_exit --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=malloc --export=free --export=__cxa_is_pointer_type --export=setThrew --export=__cxa_can_catch --export=saveSetjmp --export=__dl_seterr --export=htons --export=emscripten_builtin_memalign --export-table -z stack-size=5242880 --initial-memory=16777216 --entry=main --max-memory=2147483648 --global-base=1024' failed (returned 1)
CMakeFiles\occt-webgl-sample.dir\build.make:165: recipe for target 'occt-webgl-sample.js' failed
mingw32-make[2]: *** [occt-webgl-sample.js] Error 1
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/occt-webgl-sample.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/occt-webgl-sample.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
emmake: error: 'C:\MinGW\bin\mingw32-make.exe install' failed (returned 2)

I has added the harfbuzz libraries:

D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libharfbuzz.a D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libharfbuzz-subset.a
Lee Dongming's picture

Solved all the problems!!!

>emmake make install
make: C:\MinGW\bin\mingw32-make.exe install
[ 33%] Linking CXX executable occt-webgl-sample.js
[100%] Built target occt-webgl-sample
Install the project...
-- Install configuration: ""
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.js
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.wasm
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.html
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/OCC_logo.png
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lamp.ico