Questions tagged [emscripten]

0

votes
0

answer
3

Views

How can I import Emscripten generated .wasm/js files in files created with create-react-app

I have a library I can successfully build & run with the Emscripten generated .html files. I'd like to use it with React now, however, I get a MIME type error` which I can't fix. Here are the steps I take to generate the React app and .wasm files npx create-react-app stackoverflow DEST=stackoverfl...
Marvin Irwin
1

votes
0

answer
7

Views

Problem connecting websocket from c++ compiled with emscripten

Trying to connect to websocket (poco-1.9.0 samples\WebSocketServer) using c++ code compiled with emscripten. Using compiled boost 1.69 and one of common examples to connect to socket. boost::asio::ssl::context ctxt(context::sslv23_client); ctxt.set_verify_mode(boost::asio::ssl::verify_none); boost:...
Laza
1

votes
1

answer
126

Views

Fatal Error on Compiling the PDF2SVG with Emscripten

For some reasons I needed to be use PDF2SVG (https://github.com/dawbarton/pdf2svg) in browser envoirment; to accomplish that I wanted to use Emscripten. So I followed the steps that described in their site. But I am always getting this error: tests/pdf2svg/pdf2svg.c:24:10: fatal error: 'glib.h' file...
Digerkam
1

votes
0

answer
239

Views

emscripten: Memory leak with std::vector & std::map in c++ code

I want to know how to properly delete the memory of std::vector & std:: map allocated in c++ code. I am sharing my code here # include # include # include //realloc # include # include # include #include using namespace emscripten; struct Edge{ // Coordinates of two vertices float c[6]; float...
Srinivas
1

votes
0

answer
274

Views

Installing Emscripten, LLVM version appears incorrect

I'm trying to install the emscripten SDK on Linux and can't figure out the source of this error. I've intsalled using ./emsdk install latest ./emsdk activate latest Any call to emcc gives this message WARNING root: LLVM version appears incorrect (seeing 'version', expected '3.2') INFO root: (...
Jay
1

votes
0

answer
263

Views

How to produce .wasm file using emmake

I have this project skeleton on github The project allows to move a cursor using SDL lib. Which I want to port afterward into browser. The files were generated based on this turorial MouseMove/src/main.cpp: #include #include #include int main(int, char**){ if (SDL_Init(SDL_INIT_VIDEO) != 0){ std:...
deathangel908
1

votes
0

answer
248

Views

ERROR:root:compiler frontend failed to generate LLVM bitcode, halting mingw32-make: *** [obj/pgText.o] Error 1 mingw32-make: write error

I got continuously this error anyone has the solution for this. ERROR:root:compiler frontend failed to generate LLVM bitcode, halting mingw32-make: *** [obj/pgText.o] Error 1 mingw32-make: write error The terminal process terminated with exit code: 1 Terminal will be reused by tasks, press any key t...
Sushil Ranjan
1

votes
1

answer
74

Views

Load .wasm object from memory [closed]

I have a tool chain, which sends sources from client side to the server and on the server generates .wasm and .js files and send it back with the response. I receive all this data in variables and then inject .js file into page but it tries to find the .wasm file on the root folder, but I only have...
jks1781
1

votes
0

answer
63

Views

Memory leak due to return statement in `puts “Hello World”` method

Trying to port Ruby 1.8.7 to emscripten, I have an infinite loop that does some things with ruby, using the C API, by rb_eval_string. Now, if I do just a puts 'Hello World' in the loop, there is no leak. Next, if I call my_func_one from the main loop, there is still no memory leak, but for my_func_t...
PulseJet
1

votes
0

answer
52

Views

nodejs how to pass variable to c method char *

c code like int stringlen(char* p){ return strlen(p); } using emcc -s EXPORTED_FUNCTIONS='['_stringlen']' example.c -o example.js and in the nodejs,call em_module1._stringlen('sadfsa'),why return 4..... how can i pass the c type char * from nodejs?
vincent
1

votes
1

answer
469

Views

Clang gives warning about unsupported __declspec attribute

I've been trying to link a third party library to my program. The toolchain is using Clang 4.0.0 to compile (clang is being used in the toolchain by emscripten 1.37.19). I was getting an error about __declspec, and after looking it up, realized I needed to add the -fdeclspec parameter to clang. Howe...
Raelz
1

votes
1

answer
136

Views

Non-emterpreted calls during emscripten_sleep_with_yield()

I have a C routine transpiled to Javascript via the Emscripten emterpreter, that calls emscripten_sleep_with_yield(). While it is yielding, I'd like to run some non-emterpreted C code in the asynchronous callbacks. When I try to, there's an error message that says: 'This error happened during an e...
HostileFork
1

votes
0

answer
84

Views

Standalone modules with emscripten

I'm trying to use emscripten to build a side module for my JS app, so I don't need all the glue code it generates by default, and can provide the rest myself. According to https://github.com/kripken/emscripten/wiki/WebAssembly-Standalone, most unnecessary dependencies will be removed automatically,...
riv
1

votes
0

answer
68

Views

Compiling ImageMagick with Emscripten - Unresolved Symbols

I compiled ImageMagick with Emscripten with the following parameters emconfigure ./configure --prefix=/home/roman/Desktop/src/ImageMagick/out --enable-delegate-build emmake make ImageMagick compiled without issues. Now I'm trying to use the built libraries libMagick++-7.Q16HDRI.a and libMagickCore-7...
roman
1

votes
0

answer
102

Views

How to generate standalone webassembly with emscripten

The documentation offers two options: let optimizer strip unnecessary code and then replace the .js glue with your own, or use SIDE_MODULE flag. Both options result in a memory import (instead of export), and in the case of SIDE_MODULE a ton of extra imports/exports are also defined. Compare it to a...
riv
1

votes
1

answer
48

Views

how to use CTest with Node js command, for testing JS file compiled from C++ using emscripten, and use Catch2?

I am try to use Catch2 library for testing and compile it with emscripten and run the test. The directory structure of my project look like this |- CMakeLists.txt |- build |   |- ... |   |- try-test.js |   |- try-test.wasm |   |- try-test.wast |- test |   |- main.cpp |- third_party |- Catc...
janucaria
1

votes
0

answer
110

Views

Wasm: Uncaught (in promise) TypeError: Import #0 module=“env” error: module is not an object or function Promise.then (async) (anonymous) @ (index):9

I'm new to emscripten and find it very hard... I have obligation to work on windows because i have to test .exe versions of my apps. I'm on windows 7. I can compile wasm but javascript cannot read it. Here's my code. C code: char * HelloWorld () { return 'Hello World !'; } Emscripten command-line: e...
NonBinary
1

votes
0

answer
304

Views

Unity Failed running python.exe when building webgl

I'm trying to build a unity3d project, however when I do I get an error and cannot figure out where the error actually is, it started around the same time I introduced the newsoft and restsharp dll's, though the error remained after I removed those two packages. The entire message looks as followin...
Thijser
1

votes
0

answer
41

Views

Emscripten sandwiched by asynchronous Javascript Code

I'm trying to use Emscripten to write a Software to run in browser but also on other architectures (e.g. Android, PC-standalone app). The Software structure is something like this: main_program_loop() { if (gui.button_clicked()) { run_async(some_complex_action, gui.text_field.to_string()) } if (some...
matec
1

votes
1

answer
45

Views

emscripten stripping functions with -O3

I'm compiling a mildly complex project with emscripten. (At least more complex then simple examples I've found on the web.) First, I build all the individual libraries and applications and archive them (emar). Then, they are linked together into a final executable. In this project, function pointers...
Nathan S.
1

votes
1

answer
85

Views

NSPR emscripten compile assembly file '*.s'

On Compiling NSPR with emscripten, I have encountered a problem. emscripten don't know '.s' suffix, and emitted the error like shared:ERROR: os_Linux_x86.s: Input file has an unknown suffix, don't know what to do with it! Alternatively, I have compiled the file with 'clang' /Users/xxxxxx/Documents/w...
Marco Jo
1

votes
0

answer
49

Views

How do I enable webGL 2.0 API libs in emsripten C++?

I am working on trying to get the webGL2.0 features working with emscripten C++ program, and for now running on the latest firefox nightly. I am trying to test using a GL_UNIFORM_BUFFER object and hopefully make it shared by several shader programs. I set the flag -s USE_WEBGL2=1 on the compiler and...
peterk
1

votes
0

answer
47

Views

Can you exploit emscripten-compiled Wasm to run arbitrary JavaScript?

I'm trying to understand the threat level of the following scenario in a web application: Web app contains a C++ component compiled to Wasm by Emscripten Runs 3rd party Wasm blobs (assume fully untrusted) Assume neither blob can call back to JS via import/export All Wasm blobs share memory So, obvio...
Vesa Norilo
1

votes
2

answer
31

Views

How to get a filename renamed by Webpack?

I'm using a webassembly file compiled by Emscripten in my project. And since my project uses Webpack, it renames all files, then the Emscripten module can't find more the webassembly file. Then I need to get the new filename of the webassembly file to can load it. I found this workaround, but I want...
Macabeus
1

votes
2

answer
2.5k

Views

Where should .emscripten LLVM_ROOT and NODE_JS point to? (Mac OS X)

After downloading emscripten via git clone git://github.com/kripken/emscripten.git and running ./emcc a .emscripten file is created in my user root. ============================================================================== Welcome to Emscripten! This is the first time any of the Emscripten tool...
Calvin Cheng
1

votes
1

answer
434

Views

Pointer to member for std::array

Suppose I have a structure containing an array of objects of another structure type, like this: struct foo { int x, y; }; struct bar { std::array foos; }; Is it possible to portably write an expression which will evaluate to a pointer-to-member for a given attribute of a given array element? Somethi...
MvG
1

votes
1

answer
231

Views

How to recover missing structures?

This question is regarding Box2D v2.2.1 in JavaScript (compiled via Emscripten). Some structs like b2Vec2 and b2BodyDef work perfectly fine. I can create instances of both, like so: new Box2D.b2Vec2(0,0); // returns b2Vec {..} new Box2D.b2BodyDef(); // returns b2BodyDef {..} However, other structs...
Joncom
1

votes
1

answer
162

Views

Remove data file in FS module Emscripten

How to correctly remove data file in emscripten's FS? Currently i'm using: FS.truncate(..); FS.unlink(..);
1

votes
1

answer
204

Views

Do you have to free strings passed to exported C functions in Emscripten?

I found out through the Emscripten wiki (Interacting with code) that C functions called from javascript with ccall or cwrap should have char* as argument or return type when being passed or returning a string. I am not very experienced in C (the rest of my project is written in C++) but I know you n...
jPlatte
1

votes
1

answer
728

Views

How to fix compile errors when including emscripten headers?

I'm trying to use emscripten Embind to bind C++ functions to JavaScript. Unfortunately I already get compile errors when including the specific header file with #include . I checked my emscripten environment and set an additonal Include Directory in VS2013 to the absolute path of the installation fo...
trutty
1

votes
1

answer
405

Views

RTMP video with emscripten C/C++ to Javascript LLVM compiler

I understand emscripten is a super powerful way to encode C code into Javascript. Is it possible to use this for video, capture the webcam and stream this over RTMP using something like the rtmpdump library?
Ben
1

votes
1

answer
808

Views

Allocating a C struct in JavaScript with emscripten

I'm trying to call SDL_GetDisplayMode https://wiki.libsdl.org/SDL_GetDisplayMode from JavaScript. The function is exported and can be called correctly with Module.ccall, but I'm not sure how to create the SDL_DisplayMode struct so I can hand a pointer to it off to the function. From reading, it seem...
Jaiden Mispy
1

votes
1

answer
207

Views

Declaring multi-element array within EM_ASM_INT breaks compilation

I'm trying to declare a multi-element array inside an EM_ASM-style macro. This works fine when I just use plain old EM_ASM: EM_ASM({var a = [1,2];}); However, doing this within any of the EM_ASM-style macros that return a value seems to confuse the compiler. For instance: EM_ASM_INT_V({var a = [1,2]...
seaotternerd
1

votes
1

answer
124

Views

Unable to start program when running hello_world.c with Emscripten

I have a problem in running emscripten with vs 2010 here. It compiles all right for the hello_world.c from tests of emscripten, but when I choose 'start without debugging', it prompts me that Unable to start program 'D:\C_Drive\Desktop\emptest\msvc10\Emscripten\Debug\hello_world_c'. The system canno...
william007
1

votes
1

answer
608

Views

Default template arguments when using template template parameters

The following code compiles using gcc 5.2, gcc 4.9, and clang 3.7 at C++11 standard: template U * find_item(M & m, const T & t) { auto it = m.find(t); if (it != m.end()) { return &it->second; } return nullptr; } template const U * find_item(const M & m, const T & t) { auto it = m.find(t); if (it !...
Chris Beck
1

votes
1

answer
289

Views

Emscripten webworker - Own messages and dependencies

I have a C++ project that I compile to Javascript using emscripten. This works, however, for resource limits and interactivity reasons I would like to run this inside a webworker. However, my project uses the stdin. I found a way to provide my own implementation of stdin by overwriting Module['stdin...
1

votes
1

answer
662

Views

emscripten read javascript arrayBuffer in C

This code is incorrect but it tells what I am trying to do char* p = EM_ASM( var a = new ArrayBuffer(8); return a; ); What is the correct way of getting a C pointer of that javascript arrayBuffer? I only want to read the arrayBuffer not write
porente
1

votes
1

answer
77

Views

emscripten ASSERTIONS=1 generates linker error “Referencing global in another module!”

When I set '-s ASSERTIONS=1' then linker will fail with lots of 'Referencing global in another module!' messages, e.g.: Referencing global in another module! [16 x i8]* @_ZZN8nlohmann10basic_jsonINSt3__23mapENS1_6vectorENS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbxydS7_NS_14adl_ser...
hasan
1

votes
1

answer
410

Views

Save Empscripten webGL canvas as image in JS

I have an Emscripten-driven webGL canvas that I need to save as an image from a Javascript handler. Let's say there's a simple JS 'Save' button. var Exporter = { preRun: [], postRun: [], save: function() { var c=Module.canvas; var d=c.toDataURL('image/png'); var w=window.open('about:blank','image fr...
Tomas Andrle
1

votes
1

answer
293

Views

How to setup custom header fields for emscripten Fetch API from c++

C++ request looks like this emscripten_fetch_attr_t attr; emscripten_fetch_attr_init(&attr); strcpy(attr.requestMethod, 'GET'); // case 1 // static std::vector custom_headers = {'Token', '00000000', nullptr}; // attr.requestHeaders = custom_headers.data(); // case 2 static const char* custom_...
Sugar

View additional questions