MALOUDA-PSA 2024-04-14 10:19 采纳率: 90.1%
浏览 2
已结题

webassembly编译的问题2


emcc main.cpp -std=c++11 -I/usr/local/include/json -L/usr/local/lib/ -ljsoncpp

提示错误如下:
wasm-ld: warning: /usr/local/lib/libjsoncpp.a: archive member 'json_reader.cpp.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/lib/libjsoncpp.a: archive member 'json_value.cpp.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: warning: /usr/local/lib/libjsoncpp.a: archive member 'json_writer.cpp.o' is neither Wasm object file nor LLVM bitcode
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Reader::Reader()
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::Value(Json::ValueType)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::StyledWriter::StyledWriter()
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Reader::parse(std::__2::basic_istream<char, std::__2::char_traits<char>>&, Json::Value&, bool)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::getMemberNames() const
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::asString() const
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::asString() const
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::asString() const
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::operator[](char const*)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::operator<<(std::__2::basic_ostream<char, std::__2::char_traits<char>>&, Json::Value const&)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::operator<<(std::__2::basic_ostream<char, std::__2::char_traits<char>>&, Json::Value const&)
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::~Value()
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::~Value()
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::begin() const
wasm-ld: error: /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o: undefined symbol: Json::Value::end() const
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
emcc: error: '/Users/yeair/frontend/emsdk/upstream/bin/wasm-ld -o a.out.wasm /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/emscripten_temp_b4ljiy0r/main_0.o -L/usr/local/lib/ /usr/local/lib/libjsoncpp.a -L/Users/yeair/frontend/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/12/fs6h0k9n0ln7gmmgjrdkx19h0000gn/T/tmp4knkby0hlibemscripten_js_symbols.so --strip-debug --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=_emscripten_stack_alloc --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=_emscripten_stack_restore --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry --stack-first --table-base=1' failed (returned 1)

  • 写回答

2条回答 默认 最新

  • GISer Liu 2024-04-14 16:19
    关注

    该回答引用自GPT-3.5,由博主GISer Liu编写:

    这个错误主要是由于链接时未能正确找到Jsoncpp库的符号导致的。让我们一步步来解决:

    1. 确保Jsoncpp库正确安装 :首先,确保你的系统中正确安装了Jsoncpp库,并且路径是/usr/local/lib/libjsoncpp.a。你可以通过执行ls /usr/local/lib/libjsoncpp.a来确认文件是否存在。
    2. 检查Jsoncpp库版本 :确保你使用的Jsoncpp库版本与你的编译器和工具链兼容。有时候,版本不匹配也会导致链接错误。
    3. 修改编译命令 :根据报错信息,看起来编译器无法找到Jsoncpp库的符号。在你的编译命令中,应该将Jsoncpp库放在目标文件之后,这样编译器才能正确链接。你可以修改命令为:
      bashCopy code
      emcc main.cpp -std=c++11 -I/usr/local/include/json -L/usr/local/lib/ -o output.js -ljsoncpp
      
      这里-o output.js是指定输出文件的名称,你可以根据实际情况修改为你想要的名称。
    4. 可能的问题 :如果上述步骤无法解决问题,可能存在其他问题,比如Jsoncpp库版本过旧或者不兼容。你可以尝试更新Jsoncpp库或者查找其他解决方案。
      总的来说,这些步骤应该能够解决你的问题。如果你遇到了其他困难或者问题,请随时提问,我会尽力帮助你解决。

    如果该回答解决了您的问题,请采纳!如果没有,请私信联系或评论您的疑惑

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月24日
  • 已采纳回答 4月16日
  • 创建了问题 4月14日

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了