I am a beginner and I'm sure all the information is there, but I am
struggling to get even a basic example working. I can run the tutorial
example, but I can't get anything for the following:
I have converted some MATLAB .m script files to C (MATLAB can convert to C
or CPP. I've tried both C and CPP in the below information.)
MATLAB has 1 function per 1 file, so now I have two .c files with one c
function in each.
I've run emcc to convert .c to .js
When I look in the a.out.js and search for "myfunct", all I see for my
function is the following and I'm not sure how to call it in my js main
program:
/** @type {function(...*):?} */ var _myFunc = Module["_myFunc"] =
createExportWrapper("myFunc");
I've played around with many different command line parameters that I've
found on various Q&A forums, but still can't figure out how to create such
that there is a function called "myFunc" that I can call from my other js
files (actually typescript, but just assume js for this.)
This code will be run on the server side, node.js, and not on a browser.
Backend code that will call these converted MATLAB functions to generate
data.
It would be nice to have an example from beginning to end (I've been
searching and searching, but I only find answers that will say things like,
"You just need to use the xxxx option", but there is more to the puzzle
that I am missing.
It seems like the examples on emscripten site are all self contained: you
build and run them, but no example of how to convert a function and how to
integrate it (call it) from other js code. I have read the many options,
but again I am not sure exactly what to do. I've also read the comments in
the produced js file about creating a module and searched, but I am not
sure how to define a module for a function.
- What are the emcc parameters do I use?
- Can I convert just this one function or do I need to have a main()
that calls it?
- Once converted, it looks like I need to define a module for "myfunc",
but I am not sure how it is defined, when to define, do I add after into
the .js?
- What about using the WASM=0 option to only produce js and no WASM.
Maybe that is a route to take? (I tried and it produced some different code
in .js, but i'm still stuck on what to do with it.
I created the below simple function that takes a double and returns a
double for trying this. If anyone can show me the steps with this or any
HelloWorld that takes a parameter and returns it would be greatly
appreciated. (or even more complex example.)
Thank helping this newbie! :-)
*myFunc.c:*
#include "myfunc.h"
double myfunc(double myInt) {
return myInt + 50.0;
}
*myFunc.h:*
#ifndef MYFUNC_H
#define MYFUNC_H
/* Include Files */
#include "rtwtypes.h"
#include <stddef.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Function Declarations */
extern double myFunc(double myInt);
#ifdef __cplusplus
}
#endif
#endif
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/3676ee5c-6958-4192-9718-3516c7cb1b55n%40googlegroups.com.