1

我有一个程序我想通过 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. 所以我现在很困惑,非常感谢有人向我解释为什么这不起作用。

4

1 回答 1

3

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

于 2013-10-04T17:50:20.390 回答