Unknow file type: basic_oarchive.o (boost and emscripten)

天大地大妈咪最大 提交于 2021-02-10 16:55:00

问题


I'm trying to deserialize a file inside the browser (using boost.serialization). I compiled boost with emscripten apparently without issues.

When compiling (linking in fact) my program, I get the error

wasm-ld: error: unknown file type: basic_oarchive.o

Here is the minimal source to reproduce the problem

#include <iostream>
#include <fstream>
#include <boost/archive/binary_oarchive.hpp>
#include <emscripten/bind.h>

int main() {
  std::cout << "Run main" << std::endl;
  std::ofstream ofile("data.bin");
  boost::archive::binary_oarchive oTextArchive(ofile);
  return 0;
}

// Export the functions.
EMSCRIPTEN_BINDINGS(my_module) {
  emscripten::function("main", &main);
}

The CMakeLists.txt is:

cmake_minimum_required(VERSION 2.8)
project( josef )

set(CMAKE_VERBOSE_MAKEFILE ON)

set(BoostWasm_DIR "/home/laurent/libs/boost/build_wasm")

include_directories(${BoostWasm_DIR}/include)

add_executable(josef josef.cpp)

file(GLOB boost_js "${BoostWasm_DIR}/lib/*.a")
target_link_libraries( josef ${boost_js} )

The file basic_oarchive.hpp is in the directory /home/laurent/boost/build_wasm/include/boost/archive, but I never found the corresponding .o file.

Questions:

  • where is basic_oarchive.o ?
  • why does emscripten try to use a .o file instead of .a ?
  • How to fix the issue ?

EDIT: This one is probably the same issue: https://github.com/emscripten-core/emscripten/issues/9721

来源:https://stackoverflow.com/questions/61557566/unknow-file-type-basic-oarchive-o-boost-and-emscripten

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!