I have a really simple C++ project (removed as much code til the problem is still there.) Running em++ is always leading to an error, error: undefined symbol
main.cpp
#include "edgeguard.hpp"
int main()
{
EdgeGuardConfig core = EdgeGuardConfig::BuildEdgeGuard();
}
edgeguard.cpp
#include "edge-guard.hpp"
EdgeGuardConfig EdgeGuardConfig::BuildEdgeGuard()
{
}
edgeguard.hpp
class EdgeGuardConfig
{
public:
static EdgeGuardConfig BuildEdgeGuard();
};
The command I'm using is em++ ./main.cpp --std=c++17 -o ~/edgeguard-wasm/edgeguard-ft90x.html
The results are always the same:
error: undefined symbol: _ZN15EdgeGuardConfig14BuildEdgeGuardEv (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN15EdgeGuardConfig14BuildEdgeGuardEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '/home/nessdan/code/emsdk/node/14.18.2_64bit/bin/node /home/nessdan/code/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpqwnlcp5h.json' failed (returned 1)
Some other things I've tried:
- Using EMSCRIPTEN_KEEPALIVE
- Wrapping things in
extern "C" - Running with
-s ERROR_ON_UNDEFINED_SYMBOLS=0(command finishes, but HTML output logs the error in my console when I open it.) - Running with
-s LINKABLE=1 -s EXPORT_ALL=1- nothing changes, console output is the same.
I'm using the latest version of emscripten (3.1.6) and installed it fresh today (also installed and ran from my Windows computer with the exact same results.)