Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscripten遇到warning: unresolved symbol: ***funcName*** #2

Open
fanmingfei opened this issue Jun 15, 2017 · 0 comments
Open

emscripten遇到warning: unresolved symbol: ***funcName*** #2

fanmingfei opened this issue Jun 15, 2017 · 0 comments

Comments

@fanmingfei
Copy link
Member

fanmingfei commented Jun 15, 2017

运行

 emcc -s WASM=1 -O3 -o program.js program.cpp --js-library library.js

返回

warning: unresolved symbol: _Z6funcNamev

program.js

#include <emscripten/emscripten.h>
#include <stack>

// 定义数组大小
#define N 100

// 防止 C++ 函数名被 Mangling
#ifdef _cplusplus
extern "C" {
#endif
    // 预置函数,暴露给 JS 进行处理
    extern void checku ();

    void EMSCRIPTEN_KEEPALIVE abc () {
        char a[] = "username";
        checku();
    }
#ifdef _cplusplus
}
#endif

library.js

mergeInto(LibraryManager.library, {
    checku: function() {
      console.log(123)
    }
});

笔误,踩了一个大坑。

#ifdef _cplusplus
extern "C" {
#endif

其实是 __cplusplus 前面两个下划线

#ifdef __cplusplus
extern "C" {
#endif

添加这个判断防止 C++ 函数名被 Mangling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant