C function integration problem into a chugin
Hi all, I am currently trying to create a chugin with IBNIZ http://pelulamu.net/ibniz/ (it generate weird and loud sound, take care of your ears, headphones and speakers if you try it!!). My target is to only have sound from it. Ibniz source code is C, so I added the C file defining the functions I want to reuse inside the chugin make file: C_MODULES=vm_slow.c I call 3 of these functions inside the code generated by chuginate script: ibniz class defined in ibniz.cpp (chugin cpp source file) Compilation seems ok except 2 warnings: ~/Chuck/chugins/ibniz$ make clean; make linux rm -rf vm_slow.o ibniz.o ibniz.chug gcc -D__LINUX_ALSA__ -I../chuck/include/ -fPIC -O3 -c -o vm_slow.o vm_slow.c g++ -D__LINUX_ALSA__ -I../chuck/include/ -fPIC -O3 -c -o ibniz.o ibniz.cpp In file included from ibniz.h:12:0, from ibniz.cpp:15: vm.h:46:3: warning: anonymous type with no linkage used to declare variable '<anonymous struct> vm' with linkage [enabled by default] ibniz.cpp: In constructor 'ibniz::ibniz(double)': ibniz.cpp:45:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] gcc -shared -lstdc++ -o ibniz.chug vm_slow.o ibniz.o Then I perform the: sudo make install And the problem occurs when I try to launch a test.ck file [test.ck]:line(1): undefined type 'ibniz'... [test.ck]:line(1): ... in declaration ... I added verbose option 3 to check what goes wrong and I found that my ibniz.chug is not loaded cause of the following error: [chuck]:(3:SEVERE): | | error loading chugin 'ibniz.chug', skipping [chuck]:(3:SEVERE): | | error from chuck_dl: '/usr/lib/chuck/ibniz.chug: undefined symbol: _Z6vm_runv' vm_run() is one of the C functions I call in the chugin cpp file. So I suppose _Z6vm_runv is linked to it. As a test, I tried to remove all these C functions and the chugin is loading and running. So I think I made something wrong to integrate these functions correctly inside the chugin code. Any idea? What is chuck_dl? Thanks for your help. Ju
Hi again,
I solved the problem. In fact it is not related to chuck or chugin but more
related to C and C++ (and my poor knowledge of this last one).
When including C function in a C++ project .h files must be modified like
this to declare prototypes:
#ifdef __cplusplus
extern "C" {
#endif
// Your C prototypes
#ifdef __cplusplus
}
#endif
I understand this might be obvious for many of you, so I apologize for the
noise on the mailing list.
Have fun,
Ju
2013/1/12 Julien Saint-Martin
Hi all,
I am currently trying to create a chugin with IBNIZ http://pelulamu.net/ibniz/ (it generate weird and loud sound, take care of your ears, headphones and speakers if you try it!!). My target is to only have sound from it.
Ibniz source code is C, so I added the C file defining the functions I want to reuse inside the chugin make file: C_MODULES=vm_slow.c
I call 3 of these functions inside the code generated by chuginate script: ibniz class defined in ibniz.cpp (chugin cpp source file)
Compilation seems ok except 2 warnings:
~/Chuck/chugins/ibniz$ make clean; make linux rm -rf vm_slow.o ibniz.o ibniz.chug gcc -D__LINUX_ALSA__ -I../chuck/include/ -fPIC -O3 -c -o vm_slow.o vm_slow.c g++ -D__LINUX_ALSA__ -I../chuck/include/ -fPIC -O3 -c -o ibniz.o ibniz.cpp In file included from ibniz.h:12:0, from ibniz.cpp:15: vm.h:46:3: warning: anonymous type with no linkage used to declare variable '<anonymous struct> vm' with linkage [enabled by default] ibniz.cpp: In constructor 'ibniz::ibniz(double)': ibniz.cpp:45:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] gcc -shared -lstdc++ -o ibniz.chug vm_slow.o ibniz.o
Then I perform the: sudo make install
And the problem occurs when I try to launch a test.ck file [test.ck]:line(1): undefined type 'ibniz'... [test.ck]:line(1): ... in declaration ...
I added verbose option 3 to check what goes wrong and I found that my ibniz.chug is not loaded cause of the following error:
[chuck]:(3:SEVERE): | | error loading chugin 'ibniz.chug', skipping [chuck]:(3:SEVERE): | | error from chuck_dl: '/usr/lib/chuck/ibniz.chug: undefined symbol: _Z6vm_runv'
vm_run() is one of the C functions I call in the chugin cpp file. So I suppose _Z6vm_runv is linked to it.
As a test, I tried to remove all these C functions and the chugin is loading and running. So I think I made something wrong to integrate these functions correctly inside the chugin code.
Any idea? What is chuck_dl?
Thanks for your help. Ju
On Sat, Jan 12, 2013 at 02:43:35PM +0100, Julien Saint-Martin wrote:
Hi all,
I am currently trying to create a chugin with IBNIZ [1]http://pelulamu.net/ibniz/ (it generate weird and loud sound, take care of your ears, headphones and speakers if you try it!!). My target is to only have sound from it.
We are a serious mailinglist and so it might be inappropriate for me to suddenly express my love for another man here, or curse to express my happiness. I'd like to know what the strongest expression of of enthusiasm that I could send yet that would still be appropriate is. ;-) Also read the other mail; congrats on finding the issue. This will be *really* cool, looking forward to seeing this. Yours, Kas.
That looks soooooo cool… I can't wait! ///\/\\\ -- Michael Clemow http://michaelclemow.com http://abattoirprojects.com On Saturday, January 12, 2013 at 10:58 AM, Kassen wrote:
On Sat, Jan 12, 2013 at 02:43:35PM +0100, Julien Saint-Martin wrote:
Hi all,
I am currently trying to create a chugin with IBNIZ [1]http://pelulamu.net/ibniz/ (it generate weird and loud sound, take care of your ears, headphones and speakers if you try it!!). My target is to only have sound from it.
We are a serious mailinglist and so it might be inappropriate for me to suddenly express my love for another man here, or curse to express my happiness. I'd like to know what the strongest expression of of enthusiasm that I could send yet that would still be appropriate is. ;-)
Also read the other mail; congrats on finding the issue. This will be *really* cool, looking forward to seeing this.
Yours, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu (mailto:chuck-users@lists.cs.princeton.edu) https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (3)
-
Julien Saint-Martin
-
Kassen
-
Michael Clemow