emscripten-core / emscripten-core/emscripten

Cannot build MyMonero library

Open
#12,528 3 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Good afternoon

I'm attempting to compile a WASM library, and I'm having issues with it.

When compiling it without changing the CMakeLists.txt, I receive the following warnings:

```[100%] Linking CXX executable MyMoneroLibAppCpp_WASM.js
emcc:WARNING: --llvm-lto ignored when using llvm backend
em++: warning: boost/lib/libboost_chrono.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
em++: warning: boost/lib/libboost_chrono.a: adding index [-Wemcc]
em++: warning: boost/lib/libboost_system.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
em++: warning: boost/lib/libboost_system.a: adding index [-Wemcc]
em++: warning: boost/lib/libboost_thread.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
em++: warning: boost/lib/libboost_thread.a: adding index [-Wemcc]
warning: undefined symbol: _ZN5boost6thread20hardware_concurrencyEv (referenced by top-level compiled C/C++ code)
[100%] Built target MyMoneroLibAppCpp_WASM
```
When using this WASM file while attempting to build MyMonero's desktop app, it threw an exception due to _ZN5boost6thread20hardware_concurrencyEv not being defined.

I figured this had something to do with threads, so I added "-pthread" to the CMakeLists.txt which seems to have solved the problem around _ZN5boost6thread20hardware_concurrencyEv being undefined. I'm now met with the following error:

```[ 98%] Building C object CMakeFiles/MyMoneroLibAppCpp_WASM.dir/src/submodules/mymonero-libapp-cpp/src/mymonero-core-cpp/contrib/monero-core-custom/contrib/libsodium/src/crypto_verify/verify.c.o
[100%] Linking CXX executable MyMoneroLibAppCpp_WASM.js
emcc:WARNING: --llvm-lto ignored when using llvm backend
em++: error: no input files
make[2]: *** [MyMoneroLibAppCpp_WASM.js] Error 1
make[1]: *** [CMakeFiles/MyMoneroLibAppCpp_WASM.dir/all] Error 2
make: *** [all] Error 2
```
The `emcmake cmake .. ` command outputs the following:
```
configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/karlbuys/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/Users/karlbuys/emsdk/node/12.18.1_64bit/bin/node"
-- EMCC_LINKER_FLAGS__WASM -Wall -std=c++11 --bind -s MODULARIZE=1 -s 'EXPORT_NAME="MyMoneroLibAppCpp"' --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ASSERTIONS=2 -s EXIT_RUNTIME=0 -s PRECISE_F32=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXCEPTION_DEBUG=1 -s DEMANGLE_SUPPORT=1 -s NO_DYNAMIC_EXECUTION=1 -s NODEJS_CATCH_EXIT=0 -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]' -pthread
-s WASM=1 -Oz -s ALLOW_MEMORY_GROWTH=1 --post-js /Users/karlbuys/Sites/github/mymonero-libapp-js/src/module-post.js
```
When I review CMakeFiles/MyMoneroLibAppCpp_WASM.dir/link.txt, it has an input listed:
```
/Users/karlbuys/emsdk/upstream/emscripten/em++ -std=c++11 -Wall -std=c++11 --bind -s MODULARIZE=1 -s 'EXPORT_NAME="MyMoneroLibAppCpp"' --llvm-lto 1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ASSERTIONS=2 -s EXIT_RUNTIME=0 -s PRECISE_F32=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXCEPTION_DEBUG=1 -s DEMANGLE_SUPPORT=1 -s NO_DYNAMIC_EXECUTION=1 -s NODEJS_CATCH_EXIT=0 -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]' -pthread
-s WASM=1 -Oz -s ALLOW_MEMORY_GROWTH=1 --post-js /Users/karlbuys/Sites/github/mymonero-libapp-js/src/module-post.js @CMakeFiles/MyMoneroLibAppCpp_WASM.dir/objects1.rsp -o MyMoneroLibAppCpp_WASM.js @CMakeFiles/MyMoneroLibAppCpp_WASM.dir/linklibs.rsp
```
linklibs.rsp includes the following: `boost/lib/libboost_chrono.a boost/lib/libboost_system.a boost/lib/libboost_thread.a`

Any assistance in this regard would be greatly appreciated.

## Steps to reproduce

1. Set up emsdk
2. Install and activate 2.0.4, and run source “emsdk_env.sh”
3. git clone https://github.com/karlbuys/mymonero-libapp-js.git
4. cd mymonero-libapp-js
5. mkdir contrib
6. cd contrib
7. wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.gz
8. tar -xvzf boost_1_74_0.tar.gz
9. mv boost_1_74_0 boost-sdk
10. cd ..
11. bin/build-boost-emscripten.sh
12. bin/build-emcpp.sh

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.