I have a single file C++ lib with header file. Files are attached below. Works fine for desktop builds (MacOS and Linux).
I just try to build it with emscripten(using latest: 1.37.34) for html.
em++ -O3 -std=c++11 AABB.cc -c -o AABB.o // I try it without -std flag
emar rcs libaabb.a AABB.o
emranlib libaabb.a
When I try to build it, having a JS error. Not sure what is going on but it looks like C++ class is not initialized.
When I call the class method: xx = new aabb::Tree(…) it fails.
lib.zip (10.2 KB)
What did I do wrong? Did I miss something?
I think the lib seems ok. I think it’s something related to the setup of your extension. What’s the folder structure, what folder did you put the library in?
It is in /lib/js-web folder.
Hmm, not really sure as to why it doesn’t find that symbol.
Did you get any warnings/errors from the build?
Also, I assume the function is inside the library, but you could check nonetheless, by calling:
nm ./lib/js-web/libaabb.a | c++filt -n
(or similar for another platform)
1 Like
No I don’t have any errors, just warnings for “auto” specifier.
Hmm… nm doesn’t list the symbols for this one … 
nm libaabb.a | c++filt -n
nm: libaabb.a(AABB_28820475.o) Invalid value (Producer: 'LLVM5.0.0' Reader: 'LLVM APPLE_1_900.0.39.2_0')
Another thing, not sure if will help, but we currently use Emscripten 1.35.0.
Would you mind trying to build once again? We’ve just updated the server with some easier-to-read logging functions, which should help me locate issues a lot faster.
1 Like
Just build it.
I’m going to try it with 1.35.0.
Thank you.
Did you make a change to the code before building? Otherwise it will only find the cached version on your disc 
Actually yes, I rebuild the lib and replace it. But I’m going to change the code now and build it again.
1 Like
It should be build on server this time?
Hmm, I don’t see anything
(I’ll investigate some more)
I delete the ./internal/cache folder and build it again now.
Also I’m downloading 1.30 , going to try it out…
Thank you for your time and effort 
1 Like
@Mathias_Westerdahl I would like to inform you that build is worked with emscripten 1.30
I’m going to try it with 1.35
5 Likes
Also works with 1.35. Looks like there is a breaking changes or bug with 1.37.xx
1 Like
Yes, upgrading compiler versions always has the risk of breaking the ABI. A bit weird though that the emscripten compiler didn’t complain. Also very good to know about this, since we’d like to upgrade “soon” to 1.37.x, to allow us to test with webassembly. I’m glad you’re back on track, and thanks for the help figuring this out!
5 Likes