wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.59k stars 794 forks source link

Undefined C++ API symbols #3754

Open ashtonmeuser opened 1 year ago

ashtonmeuser commented 1 year ago

Describe the bug

Wasmer static lib does not seem to contain C++ symbols.

#include "wasm.hh"

inf main() {
  auto engine = wasm::Engine::make();
}
g++ -o src/mylib.os -c -std=c++17 -arch x86_64 -g -O3 -fPIC -I. -Iwasmer/include src/mylib.cpp
g++ -o mylib.dylib -arch x86_64 -framework Security -dynamiclib src/mylib.os wasmer/lib/libwasmer.a

Produces the following error.

Undefined symbols for architecture x86_64:
  "wasm::Config::make()", referenced from:
      ... in mylib.os
  "wasm::Config::~Config()", referenced from:
      ... in mylib.os
  "wasm::Config::operator delete(void*)", referenced from:
      ... in mylib.os
  "wasm::Engine::make(std::__1::unique_ptr<wasm::Config, std::__1::default_delete<wasm::Config> >&&)", referenced from:
      ... in mylib.os
  "wasm::Engine::~Engine()", referenced from:
      ... in mylib.os
  "wasm::Engine::operator delete(void*)", referenced from:
      ... in mylib.os
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce

  1. Use Wasm C++ API e.g. wasm::Engine::make()
  2. Compile
  3. Link Wasmer lib

Expected behavior

Wasm C++ API is usable and symbols are defined in libwasmer.a.

Actual behavior

Wasm C++ symbols are undefined in libwasmer.a.

Michael-F-Bryan commented 1 year ago

Thanks for letting us know about this @ashtonmeuser! This seems like a regression in what goes into our libwasmer.a. For the meantime, you should be able to use the C API.

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

pterror commented 5 months ago

(this is still an issue over one year later btw)

benrussell commented 2 months ago

+1

jecluis commented 1 month ago

I'd love this fixed too.

Alternatively, any chance someone could give me the gist of how these symbols should be produced? I'm happy to attempt a fix.