i'm do something like you.In my opinion, using STL in WASM is very difficult.
My solution is to create a simulate vector.Wasm only supports int32, int64, float32 and float64 and wasm's adderess is differnt from other process.So it is not feasible to import the library directly. You can call the library function through a proxy or conversion.Or you can write it by yourself.
In this case, vector
can't be imported directly.You can create a class named vector
,and implement the push_back
function.
class vector{
public:
bool push_back(int i){
// do something
}
int& at(uint index){
// do something
}
private:
int* int_ptr;
}
More details here
https://aransentin.github.io/cwasm/