I have a file called "speed.c" which I wish to use for a web program
This works:
gcc speed.c -lcrypto -lssl
But this doesn't:
emcc speed.c -v -lcrypto -lssl -s EXPORTED_FUNCTIONS=_speed,_main -o speed.wasm
The function within speed.c is called "speed". On the website for Emscripten, it says that the compiler is just like any other so this one confuses me. Any help? Thanks!
Emscripten can't use you system's libraries. This is because they are binaries compiled for your own machine (probably 64-bit linux), while
emcc
compiles to WebAssembly/JavaScript. You can generally see what architecture a binary is targeting withfile
:Thus, you will need to first compile OpenSSL with
emcc
. I haven't done this myself, but I believe it's possible. You could check out this github issue. Once you've done that you should have two files namelibssl.a
andlibcrypto.a
. Then you can compile your own project like this:Take a look at the project building page if you haven't yet.