emscripten

Not able to bind function in emscripten

谁都会走 提交于 2021-02-11 14:56:26
问题 I am trying to use emscripten to call my c/c++ function from js. For this, I am referring this tutorial : https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#embind I am following the process mentioned in this article but lerp function is not getting exported to Module and I am getting TypeError: Module.lerp is not a function in my browser console. I am just using the files mentioned in this article without any modification but still failing to

Is there a more efficient way to return arrays from C++ to javascript?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 18:15:08
问题 To pass typed array from emscripten'ed C++ to javascript I came up with this code #include <emscripten/bind.h> #include <emscripten/val.h> auto test(const emscripten::val &input) { const auto data = emscripten::convertJSArrayToNumberVector<float>(input); // copies data // generate output in some form std::vector<float> output = { 1, 2, 3 }; // make a typed array view of the output emscripten::val view{ emscripten::typed_memory_view(output.size(), output.data()) }; // create new typed array to

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

How do I set up a basic C++/C compile, and then link script for emscripten builds

邮差的信 提交于 2021-02-08 07:32:35
问题 This test if in preparation for writing a more fully fledged build module. But I need to sus out the basics first. The desire to: - build all the "object files" output to an output folder - link them into a distributable "wasm" binary and format an html page and output them to a "dist" folder. I looked at the manual in: https://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html It's not as intuitive or explicitly spelled out as one would want. Below is my current simple test

Compiling R functions to JavaScript with Emscripten

余生颓废 提交于 2021-02-07 20:38:37
问题 I'm trying to compile some R functions, written in C, to JavaScript using Emscripten. My first mission is to port a function called pf . The source can be found here. So, I go into the src directory and try running: (trunk)⚡ % emcc -s EXPORTED_FUNCTIONS="['_Rf_pf']" nmath/pf.c warning: unresolved symbol: Rf_pbeta warning: unresolved symbol: Rf_pchisq warning: unresolved symbol: R_NaN warning: unresolved symbol: R_NegInf warning: unresolved symbol: R_PosInf I get a function _Rf_pf in the

Compiling R functions to JavaScript with Emscripten

旧城冷巷雨未停 提交于 2021-02-07 20:35:41
问题 I'm trying to compile some R functions, written in C, to JavaScript using Emscripten. My first mission is to port a function called pf . The source can be found here. So, I go into the src directory and try running: (trunk)⚡ % emcc -s EXPORTED_FUNCTIONS="['_Rf_pf']" nmath/pf.c warning: unresolved symbol: Rf_pbeta warning: unresolved symbol: Rf_pchisq warning: unresolved symbol: R_NaN warning: unresolved symbol: R_NegInf warning: unresolved symbol: R_PosInf I get a function _Rf_pf in the

How do I add objects with a custom extension to a cmake library?

巧了我就是萌 提交于 2021-02-07 20:10:54
问题 I'd like to add some object files to a CMake static library, but they have a custom extension. Here's what I've tried: set(SRCS testfile.cxx jsobj.js) add_library(testlib STATIC ${SRCS}) When made, CMake invokes ar testfile.cxx.o (ie the other file is completely ignored). How do I get it included in the archive? Here are some other tricks I've tried: list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS js) list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS js) # no luck add_custom_command(OUTPUT ${CMAKE

How do I add objects with a custom extension to a cmake library?

南楼画角 提交于 2021-02-07 19:58:35
问题 I'd like to add some object files to a CMake static library, but they have a custom extension. Here's what I've tried: set(SRCS testfile.cxx jsobj.js) add_library(testlib STATIC ${SRCS}) When made, CMake invokes ar testfile.cxx.o (ie the other file is completely ignored). How do I get it included in the archive? Here are some other tricks I've tried: list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS js) list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS js) # no luck add_custom_command(OUTPUT ${CMAKE

cv::imdecode an image from JS to C++ (opencv, emscripten)

爱⌒轻易说出口 提交于 2021-02-05 08:24:33
问题 What I'm trying to do: the user loads an image in html opencv receives that image in C++ and do some work on it. What I've done is more or less the same as described here : https://answers.opencv.org/question/222994/how-to-pass-image-data-from-javascript-to-opencv-c-webassembly/ Here is the javascript part (verbatim from the given link): var openFile = function (e) { const fileReader = new FileReader(); fileReader.onload = (event) => { const uint8Arr = new Uint8Array(event.target.result);

“Failed to run llvm optimizations” using clang++ for webassmebly

南笙酒味 提交于 2021-01-29 17:31:25
问题 I've installed emscripten-1.38.27 1 and fastcomp-clang-e1.38.27-64bit via the official emsdk tool. After running qmake and gettting no errors nor warnings,I ran make for my Qt project and that resulted in this(with EMCC_DEBUG=1 ): shared:DEBUG: executed emsdk-master/fastcomp-clang/e1.38.27_64bit/clang++ -target asmjs- unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=38 -D__EMSCRIPTEN_tiny__=27 -D_LIBCPP_ABI_VERSION=2 -Werror=implicit-function-declaration -nostdinc -Xclang