grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

How to deal faust with Openframeworks(duplicate symbol) #83

Closed tomoyanonymous closed 4 years ago

tomoyanonymous commented 7 years ago

Hi, I'm trying to make a smooth workflow of faust inside openframeworks. There's also ofaudio-dsp.h, and I'm working on integration with ofxGUI which generates faust UI in app automatically and it's near to finish ;).

The main problem is a external math function such as mydsp_faustpower2_f. Usually, in OF, all headers are included or some class definitions are made at ofApp.h. ofApp.h is included by both of ofApp.cpp(which implements actual application) and ofMain.h (which have main function). So if we have mydsp_faustpower2_f function in ofApp.h, the linker gets error as below.

duplicate symbol __Z19mydsp_faustpower2_ff in:
    /Users/Tomoya/Library/Developer/Xcode/DerivedData/ofxFaust_firstexample-ejvplekuippoikdmapalgmheskym/Build/Intermediates/ofxFaust_firstexample.build/Debug/ofxFaust_firstexample.build/Objects-normal/x86_64/main.o
    /Users/Tomoya/Library/Developer/Xcode/DerivedData/ofxFaust_firstexample-ejvplekuippoikdmapalgmheskym/Build/Intermediates/ofxFaust_firstexample.build/Debug/ofxFaust_firstexample.build/Objects-normal/x86_64/ofApp.o
ld: 1 duplicate symbol for architecture x86_64

I tried to change mydsp_faustpower2_f into static function by hand and it got success.

Can't they be changed to the static function or move inside mydsp?

sletz commented 7 years ago

Can you send me an example project that shows the problem ? Thanks.

tomoyanonymous commented 7 years ago

ah, I found this thread. It seems to be discussing this problem. https://sourceforge.net/p/faudiostream/mailman/message/35158202/

I'll upload my repository soon, thanks.

sletz commented 7 years ago

Yes, I remember the issue also now. But as explained Kjetil Matheussen patch proposal was not the way to go. Time to find a more fondamental for now.

tomoyanonymous commented 7 years ago

https://github.com/tomoyanonymous/ofxFaust

In a example, now only ofxFaustGui.h is used. and it's an architecture file. mydsp.cpp is the compiled file. Compiler version is v2.3.14.

sletz commented 7 years ago

Could you test version 2.3.16 here : d33a28dce6dfd289aa2a2f5035c8e4c3e241e0fc ?

BTW, "I'm working on integration with ofxGUI which generates faust UI in app automatically and it's near to finish". Do you plan to make a contribution to the Faust architecture file system, to be added on Faust GIT? This would be very cool..

tomoyanonymous commented 7 years ago

It worked!! Thanks...

Do you plan to make a contribution to the Faust architecture file system, to be added on Faust GIT? This would be very cool..

If you OK, I'll make a pull request soon!! To say more, I want to make ofaudio-dsp.h more useful because the way to use ofSoundBuffer instead of float* is now more general.

And also ofSoundObject, a general sound effect framework for OF, seems easier to make an architecture file for faust.

https://github.com/roymacdonald/ofxSoundObjects

At first It's developed as a core feature, but haven't merged yet.

sletz commented 7 years ago

OK great !

Note that ofaudio-dsp.h file is currently used when doing faust2api -of yourFaustCode.dsp, so be sure that any change does not break this script.

And so waiting for the PR !

MacroMachines commented 6 years ago

<3

sletz commented 6 years ago

What do you mean ?

MacroMachines commented 6 years ago

its the shape of a heart, as in this is something that sounds exciting and I <3 it, looking forward to trying it out