emmake: error: unable to find library -lTKernel

guys! I am trying to use emmake to compile a project containing OpenCascade api. When I used cmake .. and make commands, everying works fine! Note that I already installed OpenCascade on my machine. My CMakeLists.txt is as follow:

cmake_minimum_required (VERSION 3.0.0 FATAL_ERROR)
project(LessonOCAF CXX)
find_package(OpenCASCADE)
include_directories(SYSTEM ${OpenCASCADE_INCLUDE_DIR})
add_executable(LessonOCAF
    main.cpp
)
foreach(LIB ${OpenCASCADE_LIBRARIES})
    target_link_libraries(LessonOCAF debug   ${OpenCASCADE_LIBRARY_DIR}/lib${LIB}.so)
    target_link_libraries(LessonOCAF optimized ${OpenCASCADE_LIBRARY_DIR}/lib${LIB}.so)
endforeach()

My main.cpp is as follow:

#include <BRepPrimAPI_MakeBox.hxx>
#include <iostream>
using namespace std;

int main(int argc, char** argv)
{
    BRepPrimAPI_MakeBox mkBox(10, 20, 30);
    mkBox.Build();

    if (!mkBox.IsDone()) {
        return 1;
    }
    
    const TopoDS_Shape& shape = mkBox.Shape();
    cout << "successfully run occt demo! " << endl;
    return 0;
}

However, when I used emmake cmake .. and emmake make, I got errors:

wasm-ld: error: unable to find library -lTKernel
wasm-ld: error: unable to find library -lTKMath
wasm-ld: error: unable to find library -lTKG2d
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
em++: error: '/emsdk/upstream/bin/wasm-ld -o LessonOCAF.wasm CMakeFiles/LessonOCAF.dir/main.cpp.o -lTKernel -lTKMath -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lTKPrim -lTKBO -lTKShHealing -lTKBool -lTKHLR -lTKFillet -lTKOffset -lTKFeat -lTKMesh -lTKXMesh -lTKService -lTKV3d -lTKOpenGl -lTKMeshVS -lTKCDF -lTKLCAF -lTKCAF -lTKBinL -lTKXmlL -lTKBin -lTKXml -lTKStdL -lTKStd -lTKTObj -lTKBinTObj -lTKXmlTObj -lTKVCAF -lTKXSBase -lTKSTEPBase -lTKSTEPAttr -lTKSTEP209 -lTKSTEP -lTKIGES -lTKXCAF -lTKXDEIGES -lTKXDESTEP -lTKSTL -lTKVRML -lTKXmlXCAF -lTKBinXCAF -lTKRWMesh -lTKDraw -lTKTopTest -lTKOpenGlTest -lTKViewerTest -lTKXSDRAW -lTKDCAF -lTKXDEDRAW -lTKTObjDRAW -lTKQADraw -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpghojnhoolibemscripten_js_symbols.so --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --no-entry --stack-first' failed (returned 1)
make[2]: *** [CMakeFiles/LessonOCAF.dir/build.make:155: LessonOCAF] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/LessonOCAF.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
emmake: error: 'make' failed (returned 2)

Is there any way to fix this problem? Many thanks!!!

  • Have you compiled the libraries mentioned with emscripten?

    – 




  • What is content of OpenCASCADE_LIBRARIES variable which you create? (You could print the value of the variable using e.g. message(STATUS "OpenCASCADE_LIBRARIES: ${OpenCASCADE_LIBRARIES}").

    – 

Leave a Comment