Make error: emmake make results in error when trying to build libxml2, can't find libxml.so.2

Make error: emmake make results in error when trying to build libxml2, can't find libxml.so.2

我的目标是使用 emscripten(我通过 emsdk 安装)将我的 C 程序编译为 wasm。它使用 libxml2。我正在按照此处列出的步骤 https://github.com/kripken/xml.js/blob/master/script/libxml2 进行构建 使用适当的 emscripten 参数从源中获取 libxml2。 当我 运行 emmake make 时,我收到以下警告和错误:

...

CCLD     libxml2.la
emcc: warning: linking a library with `-shared` will emit a static object file.
This is a form of emulation to support existing build systems.  
If you want to build a runtime shared library use the SIDE_MODULE setting. [-Wemcc]
emcc: warning: ignoring unsupported linker flag: `--version-script=./libxml2.syms` [-Wlinkflags]
wasm-ld: error: cannot open libxml2.so.2: No such file or directory
emcc: error: '/home/willy/emsdk/upstream/bin/wasm-ld -o .libs/libxml2.so.2.9.9 .libs/SAX.o .libs/entities.o .libs/encoding.o -L/home/willy/emsdk/upstream/emscripten/system/local/lib .libs/error.o -L/home/willy/emsdk/upstream/emscripten/system/lib .libs/parserInternals.o -L/home/willy/emsdk/upstream/emscripten/cache/wasm .libs/parser.o .libs/tree.o .libs/hash.o .libs/list.o .libs/xmlIO.o .libs/xmlmemory.o .libs/uri.o .libs/valid.o .libs/xlink.o .libs/HTMLparser.o .libs/HTMLtree.o .libs/debugXML.o .libs/xpath.o .libs/xpointer.o .libs/xinclude.o .libs/nanohttp.o .libs/nanoftp.o .libs/catalog.o .libs/globals.o .libs/threads.o .libs/c14n.o .libs/xmlstring.o .libs/buf.o .libs/xmlregexp.o .libs/xmlschemas.o .libs/xmlschemastypes.o .libs/xmlunicode.o .libs/xmlreader.o .libs/relaxng.o .libs/dict.o .libs/SAX2.o .libs/xmlwriter.o .libs/legacy.o .libs/chvalid.o .libs/pattern.o .libs/xmlsave.o .libs/xmlmodule.o .libs/schematron.o .libs/xzlib.o /home/willy/emsdk/upstream/emscripten/cache/wasm/libc.a libxml2.so.2 --relocatable -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [Makefile:1065: libxml2.la] Error 1
make[2]: Leaving directory '/home/willy/CWasmSandbox/libxml2-2.9.9'
make[1]: *** [Makefile:1484: all-recursive] Error 1
make[1]: Leaving directory '/home/willy/CWasmSandbox/libxml2-2.9.9'
make: *** [Makefile:897: all] Error 2

以我对 emscripten 的有限理解,我唯一能收集到的是它试图访问 libxml2.so.2,这在正常情况下会从 libxml2.la 生成。但是libxml2.so.2没有生成,因为emscripten不生成共享对象。这个评估是否正确?我尝试将选项 CFLAGS="-s SIDE_MODULE=1" 传递给 make,但它没有修复错误,这可能是我对构建系统的有限知识所产生的愚蠢想法。我还尝试将 libxml2.so.2 从以前的安装复制到适当的目录中,但没有成功,而且有点愚蠢,因为 emscripten 对 .so 文件没有用?我的下一步应该是什么?

最简单的方法是退出共享库。

共享模块(侧模块)有一个重要的限制:如果您要在主应用程序中使用线程,它将无法工作。

所以只需更改 ./script/libxml2

-emconfigure ../libxml2/configure --with-http=no --with-ftp=no --with-python=no --with-threads=no
+emconfigure ../libxml2/configure --with-http=no --with-ftp=no --with-python=no --with-threads=no --enable-shared=no

构建并 link ./build/.libs/libxml2.a 使用您的主应用程序。