问题
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