c++ - 使用 Emscripten 构建时出现链接器错误
问题描述
我有一个现有的 C++ 库,我正在尝试使用 Emscripten 将其移植到 Wasm。
库本身构建良好:
[ 33%] Linking CXX static library libFoo.a
[ 33%] Built target Foo
但是,我在构建测试套件时遇到了链接器错误:
[ 67%] Linking CXX executable FooTests_Run_Wasm.html
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Tests/FooTests_Run_Wasm.html] Error 1
make[1]: *** [Tests/CMakeFiles/FooTests_Run_Wasm.dir/all] Error 2
make: *** [all] Error 2
emmake: error: 'make' failed (returned 2)
这是我正在使用的链接器标志:
-fexceptions
-pthread
--bind
-s ALLOW_MEMORY_GROWTH=1
-s ERROR_ON_UNDEFINED_SYMBOLS=0
-s FILESYSTEM=0
-s LLD_REPORT_UNDEFINED=1
-s PROXY_TO_PTHREAD=1
-s SAFE_HEAP=1
-s STRICT=1
解决方案
推荐阅读
- r - 如何检查向量是否为 LIFO/FIFO 递减
- python - tf.concat 给出“形状必须至少为 2 级,但为 1 级”的错误,即使两个张量的形状相同
- java - 通过 JDBC 找出插入语句的 Yarn application_id
- c - 无论我尝试什么,我的指针/地址都是错误的
- image-processing - 如何在一个通道上使用 AlexNet
- spring-boot - Spring Security OAuth2:如何添加多个 ResourceServerConfigurer 类型的安全过滤器链?
- python - 如何从 locals() 中删除项目?
- stm32 - STM32 cubeMX:使用中断触发SPI DMA中断
- reference - 如何将借来的值包装在也是借来的值的新类型中?
- r - 如何将字符转换为持续时间?