In this tutorial it shows the following example for exporting C functions
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
I would like to do the same except that I use CMake like this
cd bin
emcmake cmake ../src
emmake make
What is the canonical way of specifying -s
in emmake? Should I add it to CMakeLists.txt
like
set(EXPORTED_FUNCTIONS '["_int_sqrt"]')
or do something similar?
What I figured out so far is that it can be achieved CMake with the following settings
Then you should be able to call C functions from javascript as follows:
And this is my definition of C function: