Search code examples
c++static-linkingemscripten

emcc static linking to cpp library


I'm trying to compile my c++ code to .wasm, but my c++ code need -Llibraries/bcrypt -lbcrypt to be compiled, how i can include the library in emcc

my g++ compile command :

g++ --std=c++11 -lbcrypt bcrypt-wasm.cpp -Llibraries/bcrypt -lbcrypt -o bcrypt-wasm

My main c++ file :

#include "bcrypt/BCrypt.hpp"
#include <iostream>

int main(){
    BCrypt bcrypt;
    std::string password = "test";
    std::string hash = bcrypt.generateHash(password);

    std::cout << hash << std::endl;
    return 1;
}

Expected Result :

Compile my c++ code to .wasm binary


Solution

  • wasm running on sandbox-mode that doesn't have access to local libraries

    more info : https://github.com/kripken/emscripten/wiki/Linking