gpt4 book ai didi

c++ - Emscripten 不从静态库链接

转载 作者:行者123 更新时间:2023-11-30 02:52:13 26 4
gpt4 key购买 nike

我有一个程序想通过 Emscripten 交叉编译。所以我创建了一个静态库 foo_core 并尝试通过以下方式将其链接到 html 页面:

$ em++ -std=c++11 -s VERBOSE=1 main.cpp.o -o example.html libfoo_core.js
VERBOSE is on, this generates a lot of output and can slow down compilation
adding ___cxa_atexit and deps atexit
adding _atexit and deps
warning: unresolved symbol: _Z12fooiiii

现在我当然会尝试找出为什么 _Z12fooiiii 丢失了。最后做:

$ grep -r _Z12fooiiii *
example.html: __Z12fooiiii(50, 50, 50, 255);
libfoo_core.js:,0,__Z12fooiiii,0,__ZNSt3__16locale5facetD2Ev,0,__ZTv0_n12_NSt3__113basic_istreamIwNS_11char_traitsIwEEED1Ev,0,__ZNSt3__112system_errorD0Ev
libfoo_core.js:function __Z12fooiiii($r, $g, $b, $a) {

显示,该函数实际上存在于 libfoo_core.js 中。所以我现在很困惑,非常感谢有人向我解释为什么这不起作用。

最佳答案

如果您编译 bitcode 并且库具有足够的 .bc(例如 libfoo_core.bc),它就可以工作!

关于c++ - Emscripten 不从静态库链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19143662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com