Comments (17)
What should I do to fix this error? I would appreciate any advice.
The first step is to read the error and interpret what it might mean.
openFrameworks is mostly C++ and while is libpd mostly C files. It looks like whoever made the script/makefile which builds the source files for the openFrameworks emscripten target did not test building C files as well as C++ files. The compiler seems to be saying "I can build C files, but not with the C++ stdlib." The quoted flag in the error message needs to be taken out where the compiler is being called to build the C file. I have no idea where and, as this is a general issue, I would ask the openFramneworks enscripten people.
Also, I have no idea if using libpd in emscripten will work, ie. audio in/out.
from ofxpd.
Okay, I could almost successfully build and run ofxPd/pdExample
using Emscripten.
Here are the full steps:
-
Download openFrameworks nightly from https://openframeworks.cc/download/
-
Download ofxPd and put it under
OF/addons
directory -
Download latest puredata src from https://github.com/pure-data/pure-data, replace the files in
ofxPd/libs/libpd/pure-data/src
andofxPd/libs/libpd/pure-data/extra/pd~
folder. -
Download puredata src for emscripten from https://github.com/claudeha/pure-data/tree/emscripten, copy and replace
d_array.c
,d_osc.c
,d_ugen.c
,m_class.c
,m_imp.h
,m_pd.c
,s_inter.c
,x_connective.c
,x_list.c
,x_misc.c
andx_text.c
inofxPd/libs/libpd/pure-data/src
folder. -
Download https://github.com/claudeha/libpd/tree/emscripten and replace
ofxPd/libs/libpd/libpd_wrapper
andofxPd/libs/libpd/cpp
folder. -
Open
ofxPd/libs/libpd/libpd_wrapper/util/ringbuffer.c
and change the line 17 to the following:
#if __STDC_VERSION__ >= 201112L && !defined(__EMSCRIPTEN__) // use stdatomic if C11 is available and emscripten is not used
-
Open
OF/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk
file and changePLATFORM_CFLAGS
toPLATFORM_CXXFLAGS
and add-s ERROR_ON_UNDEFINED_SYMBOLS=0
at the end ofPLATFORM_OPTIMIZATION_LDFLAGS_RELEASE
. -
Update
ofxPd/pdExample
usingprojectGenerator
. -
Open
ofxPd/pdExample/src/ofApp.cpp
and change the line 25 to the following:
#if defined(TARGET_LINUX_ARM) || defined(__EMSCRIPTEN__)
-
Open the Terminal, cd to emscripten folder and run
./emsdk activate latest
and then runsource ./emsdk_env.sh
. -
cd to
ofxPd/pdExample
folder and runemmake make
. -
Once the compilation is finished, run
emrun bin/pdExample.html
.
And here's the screenshot:
Although there are some errors and scope
array cannot be found, I could hear the vibrato cosine wave sound and also sound from the incoming microphone which means the Pd patch opens fine at least.
from ofxpd.
from ofxpd.
Seems like a bug then... I would expect the app to maybe not work but at least not crash. That is the point of the patch: as a test as well a showing basic functionality.
from ofxpd.
Thank you so much for your answer.
I will report here if I succeed.
P.S: It seems like there's at least one person who could compile libpd using Emscripten: https://www.reddit.com/r/puredata/comments/8g8ahc/libpd_compiled_to_llvmwasm_has_this_been_done_or/
from ofxpd.
I could successfully build ofxPd/pdExample
project using Emscripten.
Here are the steps I took:
-
Open
ofxPd/addon_config.mk
file and remove-DLIBPD_EXTRA
flag from commonADDON_CFLAGS
. -
Remove
ofxPd/libs/libpd/pure-data/extra
folder. -
Open
OF/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk
file and changePLATFORM_CFLAGS
toPLATFORM_CXXFLAGS
. -
Open
ofxPd/libs/libpd/libpd_wrapper/util/ringbuffer.c
and change the line 17 to the following:
#if __STDC_VERSION__ >= 201112L && !defined(__EMSCRIPTEN__) // use stdatomic if C11 is available and emscripten is not used
- Open
ofxPd/libs/libpd/pure-data/src/d_osc.c
and change the line 19~20 to the following:
#if defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || \
defined(ANDROID) || defined(__EMSCRIPTEN__)
- Open
ofxPd/libs/libpd/pure-data/src/d_array.c
and change the line 507~508 to the following:
#if defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || \
defined(ANDROID) || defined(__EMSCRIPTEN__)
- Open
ofxPd/libs/libpd/pure-data/src/x_misc.c
and change the line 27 to the following:
#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID) || defined(__EMSCRIPTEN__)
After these steps, I could successfully build ofxPd/pdExample
project using Emscripten.
However, when I run the project on the browser, it didn't work properly.
After some testings, I found out that ofSoundStream
doesn't work properly on Emscripten.
So I left a question on OF forum and posted an issue. I will post here again when I find a solution to fix the issue.
P.S: I accidentally found this https://mathr.co.uk/empd/#empd
from ofxpd.
Hey @danomatika, i tried to run the examples with Emscripten following the steps from @cuinjune, but without success. While it is possible to build with Emscripten (if I change the example and the patch here and there), if I use the ofxPd version that is included in OfxOfelia. It would be really great, if the official ofxPd version would be compatible with Emscripten too.
Here is a discussion (there is one issue left with pd.closePatch with the ofxPd version from @cuinjune): openframeworks/openFrameworks#6781
I can tell to you how to change the examples for Emscripten (at least pdExample and pitchShifter), if it makes sense.
from ofxpd.
@danomatika I guess this issue can be closed, because compiling with Emscripten is possible without any changes now.
from ofxpd.
Please test the develop
branch. It includes prelim pd 0.55 sources as well as updates to the scripts to allow for easier testing of libpd versions: https://github.com/danomatika/ofxPd/tree/develop?tab=readme-ov-file#trying-newer-versions-of-libpd
I don't normally use a develop branch here but this warrants additional testing in case we need to fix anything inside the Pd core itself.
from ofxpd.
@danomatika tested the pdExample with Emscripten and it works well. There are a few things that I had to change in the patch (which was also the case with earlier attempts):
[array] needs to be replaced with [array define] and [midiout], [midiin] and [sysexin] do not work and need to be removed. Those changes need to be made, otherwise the patch does not work at all.
Here is the edited patch:
test.zip
from ofxpd.
@danomatika tested the pdExample with Emscripten and it works well. There are a few things that I had to change in the patch (which was also the case with earlier attempts): [array] needs to be replaced with [array define] and [midiout], [midiin] and [sysexin] do not work and need to be removed. Those changes need to be made, otherwise the patch does not work at all. Here is the edited patch: test.zip
I'm not willing to change the default example/test patch. What do you mean by "do not work" ie. does the app crash or does the patch simply do nothing?
from ofxpd.
I'm not willing to change the default example/test patch.
Thats not what I wanted to say. I wanted to say that it is expected behavior that the pdExample does not work with Emscripten as it is (which is not a problem for me). And tell what need to be theoretically(!) changed. ofxPd
works well with Emscripten
now (as far as I can tell), which is very nice.
The app does nothing and this is the error message:
Uncaught RuntimeError: null function or function signature mismatch
at index.wasm.pd_typedmess (http://localhost:6931/index.wasm:wasm-function[306]:0x1b9a4)
at index.wasm.binbuf_eval (http://localhost:6931/index.wasm:wasm-function[320]:0x1c863)
at index.wasm.binbuf_evalfile (http://localhost:6931/index.wasm:wasm-function[2009]:0xcb758)
at index.wasm.glob_evalfile (http://localhost:6931/index.wasm:wasm-function[1248]:0x6c2b3)
at index.wasm.libpd_openfile (http://localhost:6931/index.wasm:wasm-function[1861]:0xadaa3)
at index.wasm.ofxPd::openPatch(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>> const&) (http://localhost:6931/index.wasm:wasm-function[1729]:0x96cd6)
at index.wasm.ofApp::setup() (http://localhost:6931/index.wasm:wasm-function[3529]:0x126d8e)
at index.wasm.ofNode::onParentOrientationChanged(glm::qua<float, (glm::qualifier)0>&) (http://localhost:6931/index.wasm:wasm-function[1765]:0xa0497)
at index.wasm.std::__2::__function::__func<std::__2::shared_ptr<of::priv::Function<ofKeyEventArgs, std::__2::recursive_mutex>> ofEvent<ofKeyEventArgs, std::__2::recursive_mutex>::make_function<ofMainLoop>(ofMainLoop*, void (ofMainLoop::*)(ofKeyEventArgs&), int)::'lambda'(void const*, ofKeyEventArgs&), std::__2::allocator<std::__2::shared_ptr<of::priv::Function<ofKeyEventArgs, std::__2::recursive_mutex>> ofEvent<ofKeyEventArgs, std::__2::recursive_mutex>::make_function<ofMainLoop>(ofMainLoop*, void (ofMainLoop::*)(ofKeyEventArgs&), int)::'lambda'(void const*, ofKeyEventArgs&)>, bool (void const*, ofKeyEventArgs&)>::operator()(void const*&&, ofKeyEventArgs&) (http://localhost:6931/index.wasm:wasm-function[579]:0x2fd4b)
at index.wasm.ofEvent<ofEventArgs, std::__2::recursive_mutex>::notify(ofEventArgs&) (http://localhost:6931/index.wasm:wasm-function[819]:0x43ad5)
from ofxpd.
So the problematic PD objects with Emscripten are (so far): [array], [midiout], [midiin] and [sysexin].
from ofxpd.
from ofxpd.
I made a webMIDI proposal for OF some time ago, which works quite well: openframeworks/openFrameworks#7259
Not sure, if it would make sense to integrate webMIDI into libpd somehow at some point or leave it as a seperate solution.
I get this error when I replace s_libpdmidi.c
with s_midi_dummy.c
:
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/m_glob.o: undefined symbol: glob_midi_setapi
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/m_glob.o: undefined symbol: glob_midi_properties
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/m_glob.o: undefined symbol: glob_midi_dialog
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/s_main.o: undefined symbol: sys_gui_midipreferences
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_byte
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_byte
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_byte
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_noteon
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_noteon
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_controlchange
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_controlchange
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_programchange
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_pitchbend
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_aftertouch
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_aftertouch
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_polyaftertouch
wasm-ld: error: /mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/addons/obj/emscripten/Release/ofxPD/libs/libpd/pure-data/src/x_midi.o: undefined symbol: outmidi_polyaftertouch
em++: error: '/mnt/c/Users/Jonat/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_kihhsndn.rsp.utf-8' failed (returned 1)
make[1]: *** [/mnt/c/Users/Jonat/Desktop/openFrameworks-audioWorklet-3/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:406: bin/pdExample/index.html] Error 1
from ofxpd.
I get this error when I replace
s_libpdmidi.c
withs_midi_dummy.c
Then this is probably not the right approach to fix this. Sending a message from Pd through a midi object just results in the appropriate midi hook function getting called. There is no built-in midi library, so this should not trigger a crash. It's a bug.
I would ask @claudeha or @Spacechild1 about this since now is the time to test, find bugs, and fix them if you want the fixes in pure-data or libpd any time soon...
from ofxpd.
from ofxpd.
Related Issues (20)
- [question] there's any way to avoid libPd compile build for Windows / VS 2017? HOT 26
- Using ProjectGenerator to create an iOS ofxPd project? HOT 2
- iOS can not find my patch HOT 2
- Use keyboard input on iOS? HOT 1
- error compiling pdMultiExample with PDINSTANCE and PDTHREADS HOT 9
- pdMultiExample crashes with PDINSTANCE and PDTHREADS HOT 13
- ofxPd stops recieving messages (bangs) when ofxMidi is currently running on ios HOT 1
- background audio on android and back button issue HOT 10
- writesf~ file doesn't get created on iOS 15 HOT 7
- update libpd header link HOT 1
- pd.closePatch() not working with Emscripten HOT 7
- Is it possible to load local audio files (with the file browser) into ofxPd? HOT 1
- [metro] outputs a single bang and then stops HOT 8
- cannot convert argument 1 from 'void *' to 't_pd *' HOT 10
- audioReceived & audioRequested deprecated HOT 2
- Emscripten compatible version HOT 1
- Building in Visual Studio with custom externals HOT 2
- linking error while building on win11/mingw64 HOT 6
- Cannot run ofxPd’s Example HOT 2
- Unable to detect endianness HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxpd.