最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - How to build a C++ static library for TS+WASM with Emscripten? - Stack Overflow

programmeradmin5浏览0评论

I've tried building libFLAC++ for a while now using emscripten. I added

# FLAC/CMakeLists.txt
if(DEFINED EMSCRIPTEN)
    target_link_options(FLAC++ PRIVATE
        --emit-tsd "./interface.d.ts"
    )
endif()

And I built using

emcmake cmake ../flac -DINSTALL_MANPAGES=OFF -DWITH_OGG=OFF -DBUILD_SHARED_LIBS=ON
emmake make

And that seems to successfully build the executable exports, but libFLAC++ is still built as a .a static library. So when I try to build

emcc libFLAC++.a -lembind --emit-tsd "./interface.d.ts"

The generated a.out.js seems incorrect, and the only typing that is generated is

// TypeScript bindings for emscripten-generated code.  Automatically generated at compile time.
declare namespace RuntimeExports {
    let HEAPF32: any;
    let HEAPF64: any;
    let HEAP_DATA_VIEW: any;
    let HEAP8: any;
    let HEAPU8: any;
    let HEAP16: any;
    let HEAPU16: any;
    let HEAP32: any;
    let HEAPU32: any;
    let HEAP64: any;
    let HEAPU64: any;
}
interface WasmModule {
}

export type MainModule = WasmModule & typeof RuntimeExports;
set(CMAKE_EXECUTABLE_SUFFIX ".html")
# or
set(CMAKE_EXECUTABLE_SUFFIX ".js")
# or
set(CMAKE_EXECUTABLE_SUFFIX ".ts")

Is completely unrelated and does nothing.

Same with changing CMAKE_SHARED_LIBRARY_SUFFIX and CMAKE_STATIC_LIBRARY_SUFFIX

发布评论

评论列表(0)

  1. 暂无评论