wasm-ld 链接器错误,即使库中存在符号

问题描述 投票:0回答:0

我正在尝试将 WebGPU 支持添加到编译为 WASM 的 whisper.cpp

这是我添加到 whisper.cpp 的内容:

    #include "/home/patrick/emsdk/upstream/emscripten/system/include/webgpu/webgpu.h" 
    #include "/home/patrick/emsdk/upstream/emscripten/system/include/webgpu/webgpu_cpp.h" 
    
    int CreateInstance() {    
            auto result = wgpuCreateInstance(reinterpret_cast<WGPUInstanceDescriptor const * >("test"));        
            return 0; //return Instance::Acquire(result);
        }

// also I invoke CreateInstance() later

我得到

undefined symbol: wgpuCreateInstance
wasm-ld

这是令人困惑的,因为

wgpuCreateInstance
存在于
libwebgpu_cpp.a
libwebgpu_cpp.a
中,它作为 wasm-ld 的参数存在(见下文)

$ make -j 

wasm-ld: 错误: ../../libwhisper.a(whisper.cpp.o): undefined symbol: wgpuCreateInstance em++: 错误: '/mnt/c/Users/16515/Desktop/prj/empscripten/emsdk/upstream/bin/wasm-ld -o ../../bin/libstream.wasm CMakeFiles/libstream.dir/emscripten.cpp.o ../../libwhisper.a /home/patrick/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libwebgpu_cpp.a -L/mnt/c/Users/16515/Desktop/prj/empscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /mnt/c/Users/16515/Desktop/prj/empscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crtbegin.o --whole-archive -lembind-rtti --no-whole-archive -lGL-mt -lal -lhtml5 -lstubs -lnoexit -lc-mt -ldlmalloc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++ abi-mt-noexcept-lsockets-mt-mllvm-combiner-global-alias-analysis=false-mllvm-enable-emscripten-sjlj-mllvm-disable-lsr--allow-undefined-file=/tmp/tmpphpns_kt.undefined- -import-memory --shared-memory --strip-debug --export-if-defined=main --export-if-defined=_emscripten_thread_init --export-if-defined=_emscripten_thread_exit --export-if-defined=_emscripten_thread_crashed --export-if-defined=_emscripten_tls_init --export-if-defined=pthread_self --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=stackSave --export=stackRestore --export=stackAlloc --export= __wasm_call_ctors --export=_errno_location --export=emscripten_dispatch_to _thread --export=_emscripten_thread_free_data --export=emscripten_main_browser_thread_id --export=emscripten_main_thread_process_queued_calls --export=emscripten_run_in_main_runtime_thread_js --export=emscripten_stack_set_limits --export=__get_temp_ret --export=__set_temp_ret --export=--freemallocexport=export =__cxa_is_pointer_type --export-table -z stack-size=65536 --initial-memory=1073741824 --no-entry --max-memory=1073741824 --global-base=1024' 失败(返回 1)

webassembly emscripten
© www.soinside.com 2019 - 2024. All rights reserved.