[英]Compiling C++ with external library to Wasm using Wasmer
I'm trying to compile C++ file linked with external library using Wasmer .我正在尝试使用Wasmer编译与外部库链接的 C++ 文件。
I built external library using:我使用以下方法构建了外部库:
git clone -b main https://github.com/open-quantum-safe/liboqs.git
cd liboqs
mkdir build && cd build
wasimake cmake -GNinja ..
wasimake ninja
As a result I've got liboqs.a
library which I want to reuse in code that I'm trying to compile to Wasm.结果,我得到了liboqs.a
库,我想在我试图编译为 Wasm 的代码中重用它。 Here is the code:这是代码:
#include <stdio.h>
#include <oqs/oqs.h>
int main(void)
{
uint8_t public_key[OQS_KEM_frodokem_640_aes_length_public_key];
uint8_t secret_key[OQS_KEM_frodokem_640_aes_length_secret_key];
OQS_STATUS rc;
rc = OQS_KEM_frodokem_640_aes_keypair(public_key, secret_key);
printf("%d\t", (int)rc);
return 0;
}
Compiling file with this command:使用此命令编译文件:
wasicc -I ../../build/include "liboqs.a" "example.cpp" -o example.wasm
../../build/include
- path to build folder of external library. ../../build/include
- 外部库构建文件夹的路径。
I'm getting this error:我收到此错误:
wasm-ld: error: liboqs.a(rand.c.o): undefined symbol: __memory_base
I don't understand what does this error mean and what can be the reason of it.我不明白这个错误是什么意思,可能是什么原因。 Can somebody please help me with this?有人可以帮我吗?
Not sure if this helps, but I was able to build this C file below:不确定这是否有帮助,但我能够在下面构建这个 C 文件:
cd liboqs
mkdir build && cd build
cmake -GNinja ..
wasicc \
-o example.wasm \
-I liboqs/build/include \
example.c
#include <stdio.h>
#include <oqs/oqs.h>
int main(void)
{
uint8_t public_key[OQS_KEM_frodokem_640_aes_length_public_key];
uint8_t secret_key[OQS_KEM_frodokem_640_aes_length_secret_key];
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.