Questions tagged [emscripten]

Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

How can I enhance the Emscripten performance score in Chrome Lighthouse? [closed]

How can I optimize Emscripten-generated JavaScript for a better Lighthouse score despite minor issues in the code?
Rodrigo's user avatar
  • 64
0 votes
0 answers
130 views

Is it considered good practice to ship code with an address sanitizer? [closed]

In my WebAssembly project using Emscripten, I utilize a third-party library (Lua) that has a memory alignment issue in a specific section. It works normally in all browsers except for Safari. ...
Rodrigo's user avatar
  • 64
0 votes
1 answer
46 views

Error: /src/node_modules/isolated-vm/out/isolated_vm.node: invalid ELF header

I have a very simple Dockerfile FROM emscripten/emsdk COPY . . RUN npm install --omit=dev RUN node index.js Which the following properties node --version v16.20.0 uname -a Linux buildkitsandbox 6....
Rodrigo's user avatar
  • 64
1 vote
1 answer
52 views

Emscripten handover double array - Apparently random address is received

I have trouble handing over a double array to a WASM file, that is generated via emscripten. I have generated it as a .js output file with WASM=1, so I also have a wasm file. This is my abbreviated C++...
TheCommoner282's user avatar
0 votes
0 answers
19 views

clangd not finding gnu/stubs-32.h when using emscripten

Clangd returns this error if I include anything when using a compile_commands.json generated by CMake with flags from emcc --cflags. Despite the error, the program compiles without any issue. In ...
Perigord's user avatar
  • 111
0 votes
0 answers
34 views

custom opencv.js + wasm: Using cv.matFromArray() results in cv.Mat() is not a constructor. How to load the `module` correct in Typescript?

I followed this tutorial to create a custom opencv.js [1]: https://docs.opencv.org/4.x/d4/da1/tutorial_js_setup.html But I'm stuck with the correct laoding in my Typescript project. The created script ...
user2853437's user avatar
0 votes
1 answer
35 views

Emscripten with cgal failed

First I clone this project: https://github.com/yushi-bot/CGAL_triangulation_demo. Background: I am attempting to compile a C++ program that uses the CGAL library into WebAssembly (wasm) format using ...
YI-CHENG LI's user avatar
0 votes
0 answers
27 views

Unhandled Promise Rejection: RuntimeError: Out of bounds call_indirect (evaluating '(_main=Module["_main"]=wasmExports["ge"])(a0,a1)')

I have an application written in C++ which runs fine on Chrome and Firefox. In Safari I saw this error on the console: Unhandled Promise Rejection: RuntimeError: Out of bounds call_indirect (...
Rodrigo's user avatar
  • 64
0 votes
0 answers
41 views

Is it possible to resize a canvas after transferControlToOffscreen() in wasm?

I am cross compiling to wasm a multi-threaded rendering engine. Upon spawning render thread we call emscripten_pthread_attr_settransferredcanvases which is same as calling transferControlToOffscreen() ...
Michael IV's user avatar
  • 11.1k
0 votes
1 answer
21 views

Emscripten wasmTable null when calling addFunction

I'm trying to get an older Emscripten project running in React and am having a runtime issue when I try to call addFunction. The stack trace looks like: core.js:1981 Uncaught TypeError: Cannot read ...
Brian S's user avatar
  • 11
0 votes
1 answer
42 views

Issues when build multhreaded wasm as a module

We are building emscr app that uses pthreads as a module. Here are the linker options: -sWASM=1 -sINITIAL_MEMORY=134217728 -sMAX_WEBGL_VERSION=2 -sUSE_GLFW=3 -sFULL_ES3 -sEXIT_RUNTIME -sASYNCIFY -...
Michael IV's user avatar
  • 11.1k
0 votes
1 answer
49 views

gRPC Web compilation with Emscripten

Can I compile gRPC to the Web with Emscripten? NOTE: I'm trying to compile it but it keeps giving errors, please help, NOTE: Without gRPC-Web. Thanks. I am compiling gRPC cross platform and I was able ...
Abdullah Aygün's user avatar
0 votes
1 answer
36 views

How to import class in WASM and use it out of onRuntimeInitialized?

I try to use embind to bind my c++ code to js. I find I can only use function and class in Module.onRuntimeInitilized. How can I use those functions and classes out of the onRuntimeInitilized as a ...
Roy Kid's user avatar
1 vote
0 answers
49 views

Calling putImageData from C++ wasm

I have a uint32 array in c++ wasm: int size = width * height * dpr * dpr; uint32_t *img = new uint32_t[size]; for (int i = 0; i < size; i++) { img[i] = 0xFF0000FFu; // red (at least in js, not ...
keyboqr's user avatar
  • 11
1 vote
2 answers
75 views

Unable to convert python to wasm using pyodide compiler

I am unable to convert python file to wasm file. tried with emscripten and pyodide for conversion from python to wasm. But was unable to get the proper compilation packages. It's not clear to get to ...
Monisha T's user avatar
0 votes
0 answers
40 views

how do you use emcc to compile javascript code to a wasm file?

The example I was given is: emcc sample.js -o test.wasm -s EXPORTED_FUNCTIONS="['main']" where sample.js is: function main() { console.log('hi'); } but I get wasm-ld: error: unknown ...
Andrew Arrow's user avatar
  • 4,338
0 votes
1 answer
53 views

Building OpenCV for js using Emscripten is failing

I'm trying to build OpenCV from source for JS, but have been running into an emcmake error. This is the command I'm running: emcmake python C:\OpenCV\opencv-4.7.0\platforms\js\build_js.py --...
Tarek's user avatar
  • 1
0 votes
0 answers
56 views

Emcc compiling c++ files not compiling correctly

I used to have this: void extra(int x){ printf("Here's your number: %d\n", x); } EXTERN EMSCRIPTEN_KEEPALIVE void myFunction(int x){ extra(x); } With a number input field and a ...
Deepflea18's user avatar
1 vote
0 answers
74 views

How to initialize WebGL2 Context with OffscreenCanvas in Webassembly with emscripten

I'm going to do some work in a web worker so that I can not have a canvas element on the DOM tree. However, emscripten_webgl_create_context api requires an id attached to a canvas in the DOM tree. I ...
ucag's user avatar
  • 295
0 votes
0 answers
48 views

Linking Issue with Emscripten and Ceres-Solver: "undefined symbol: typeinfo for ceres::CostFunction"

I'm working on a project that uses the Ceres-Solver library. The project compiles successfully when using a regular CMake setup. However, when I try to compile it using the Emscripten compiler, I run ...
aman's user avatar
  • 47
0 votes
1 answer
44 views

Unable to build C++ Class in JavaScript using Emscripten with generated Djinni Wrapper

I'm trying to generate an extremely simple WebAssembly module from a C++ class with an add function. Here is the source c++ class and the respective djinni file // ***src/MathUtils.cpp*** #include &...
Sam Kouteili's user avatar
0 votes
0 answers
93 views

How to use emsdk/emscripten to build c++ and reference/include gmp?

wasm-ld error: unknown file type: libgmp.a wasm-ld:error: undefined symbol: __gmpz_clear I want to build https://github.com/Iwctwbh/Factorial-BenchMark in wasm. Can you tell me the correct steps? wasm-...
Silent_Lea's user avatar
-2 votes
1 answer
45 views

Problems with callbacks using emscripten with pthreads

emscripten_set_click_callback does not work with multithreading. I'm not sure why, but certain functions like emscripten_set_click_callback and other similar input functions don't work with pthreads ...
Ross Evan's user avatar
0 votes
0 answers
45 views

Can I bind a type to a primitive representation (string, number) with Embind?

I am learning Emscripten and Embind. I have written some bindings for my types, but for all of them I receive a complex object on javascript side that must be deleted using delete(). For some things, ...
Tomáš Zato's user avatar
  • 50.7k
0 votes
1 answer
145 views

WebAudioWorklet in webassembly Shared Array Buffer not defined

I ma trying to understand how to compile an Audio Worklet in webassembly using the Wasm Audio Worklets API of the emscripten. Using the code listed in the tutorial on the API reference here and ...
ddgg's user avatar
  • 145
0 votes
1 answer
43 views

Not all overloads in a bound C++ class are available in JavaScript, using emscripten

One of the classes in a library that I want to make available via WebAssembly in JavaScript contains 3 overloads of a method: class RuleContext : public tree::ParseTree { public: virtual std::...
Mike Lischke's user avatar
  • 50.1k
0 votes
1 answer
85 views

Emspripten gives a multiple async error, while one call isn't async

From JS I pass a callback to C++. C++ calls this JS callback asynchronously. If the JS callback calls a synchronous function from C++, it works fine. If the JS callback calls an asynchronous function,...
JMRC's user avatar
  • 1,485
0 votes
0 answers
30 views

Inconsistent anti-aliasing using emscripten/c++/wasm with different browsers/machines

I'm using emscripten/c++ for a wasm module that draws some lines and some text using the emscripten canvas API. I'm calling the API with void canvasClass::draw_lines(const vector< CanvasCoordinates&...
Dan's user avatar
  • 31
0 votes
0 answers
46 views

Compiling Armadillo C++ Project to WebAssembly (WASM)

I have developed a C++ project that heavily relies on the Armadillo library for numerical computations. Now, I am interested in converting this project into a WebAssembly (WASM) module so that it can ...
pedram's user avatar
  • 335
0 votes
0 answers
29 views

ERROR: Parameter 0 has unknown type 17CameraChangeEvent?

I have been trying to call a Typescript function that I passed as a pointer into the C++ file using emscripten:: val. Thereafter, I am calling the function using the argument necessary using val. ...
addie293's user avatar
0 votes
0 answers
79 views

Calling a TypeScript method from C++ using Emscripten

The following is my TypeScript code: export class VtkWasmRenderComponent extends EmscriptenWasmComponent implements AfterViewInit, OnDestroy { ..... ..... ..... vtkCameraChanged(...
addie293's user avatar
0 votes
0 answers
122 views

CMake fails due to missing protobuf-config.cmake while compiling project using Emscripten

I'm trying to compile to WASM a C++ project that has protobuf as a dependency. To this aim, I downloaded the precompiled library from the protobuf-wasm repo's releases and modified the project's CMake ...
GTP95's user avatar
  • 13
0 votes
0 answers
23 views

Adding A SDL2 Element to the Emscripten Fullscreen Element

I was thinking it would be cool if one could refactor timhutton's code's code (which would be my SDL2 code) into emscripten's fullscreen.cpp file. I tried it out, but unfortunately, I wasn't able to ...
ichang3765's user avatar
0 votes
0 answers
51 views

Web assembly cvtColor not working properly on iOS

OpenCV cvtColor seems to not work properly on iOS with web assembly. When calling cvtColor two times in a row, the second run delivers wrong results. Using the following code snippet I can reproduce ...
Thomas Krinninger's user avatar
0 votes
0 answers
77 views

Enabling C++ linkage for Emscripten compilation

EDIT: the linkage is for the #include directives for the .h files. I figured out that the error occurs when the same #include statements is declared twice in different .cpp files. I m trying to use ...
lit's user avatar
  • 1
0 votes
0 answers
81 views

How to convert Emscripten FS error to string in Javascript

In Emscripten FS functions, FS.ErrnoError is thrown if there is an error. The error number is provided, but the error message is always 'FS error' on the Javascript side of things. Is there a way I ...
Maurice Lam's user avatar
  • 1,637
1 vote
1 answer
796 views

How can I generate typescript types for an Emscripten project?

I don't want to write TypeScript type declaration files for my Emscripten project manually. Is there a way to get such type declaration files generated automatically? Ex. for variables, functions, ...
starball's user avatar
  • 25.1k
0 votes
1 answer
120 views

WASM does not export any methods

I am using cmake v3.26.3 emsdk/emcc/em++ v3.1.43 (Emscripten) gcc/g++ v14.0.3 (Apple clang) to build a WASM. After I build the WASM file, I inspect it with wasm-objdump and notice that there is no ...
Jane Wayne's user avatar
  • 8,307
0 votes
0 answers
25 views

Emscripten AddressSanitizer leak detection

I'm trying to port a big c++ project using Emscripten, therefore I want to introduce the addressSanitizer. However I don't understand some behavior underneath and hope someone could enlighten me in ...
Zamah's user avatar
  • 33
1 vote
0 answers
226 views

Using Vite React with C++ Emscripten + Multithreaded Web Workers

I'm trying to setup a project using Vite React + C++ code compiled with Emscripten with multithreading via web workers enabled. This works fine with a development build using npm run dev but fails ...
Meowfueille's user avatar
0 votes
1 answer
85 views

Callback in C++

I am working on a wasm project where I need to define a empscripten fetch callback in a C++ header file, because I need to update a member variable. Can someone help me with how I define a callback ...
DNRN's user avatar
  • 2,417
0 votes
0 answers
33 views

Building dav1d with emscripten

Can someone please help me setup an emscripten build for dav1d project. I have a bit of experience with emconfigure ... and emmake make ... builds for other libs, however dav1d compile doc mentions ...
Yoz's user avatar
  • 747
1 vote
1 answer
70 views

Problem running emscripten c++ web application on android device for testing

I'm trying to run my web based c++ application on my android phone so i can do mobile testing with the application I'm working on. I've connected my android phone through usb, and i'm able to run ...
Josh's user avatar
  • 11
1 vote
0 answers
66 views

Pass array of data from js to cpp using WASM and Emscripten

I'm trying to send a vector<class> from js to cpp using WASM and Emscripten. I've written the cpp and bindings code, but I'm not sure how to write the js side of code. class A { public: int ...
ayush bansal's user avatar
1 vote
0 answers
43 views

Emscripten (with pthread) POST http://localhost:8080/stdio.html 405 (Method Not Allowed)

emcc 3.1.42-git I have passed in "USE_PTHREADS=1" and "-pthread" compiler flags. But still looks like ENVIRONMENT_IS_PTHREAD is undefined. (see code below) I don't find stdio.html ...
user1455545's user avatar
0 votes
1 answer
245 views

Write to filesystem using in emscripten

I have an application which runs in desktop (compiled with gcc 10 for x86_64 arch) and in emscripten (compiled with emscripten and run through nodejs). This code produces some files I need to save. In ...
jjcasmar's user avatar
  • 1,513
0 votes
1 answer
55 views

Emscripten compiling Python error: Linking globals named 'hypot': symbol multiply defined

I am trying to build Python with emscripten and link it to my main program, but during the linking stage im getting: error: Linking globals named 'hypot': symbol multiply defined! which seems to be ...
got here's user avatar
  • 391
0 votes
0 answers
66 views

i32.load error while trying to run compiled to WebAssembly C++/Raylib game

I have compiled the C++/Raylib game to the web, but after trying to run it I have seen these errors in console: Uncaught RuntimeError: memory access out of bounds at game.wasm:0x47615 at game.wasm:...
Roman Leshchuk's user avatar
0 votes
0 answers
27 views

compiling OpenHEVC with Emscripten

I'm trying to compile OpenHEVC with Emscripten, but I can't, I'm facing a lot of errors, has anyone already compiled it? the complation commands that I could find on the internet are the following: ...
Billal Goumiri's user avatar
0 votes
0 answers
50 views

How to Grab GL.currentContext from a Thread?

I'm currently trying to use GL.currentContext from my render thread (separate from the main thread). When I grab GL.currentContext by hand in the Javascript console on the main thread, it'll give me ...
Alexis's user avatar
  • 81

1
2 3 4 5
25