Discussion:
c_block 4
(too old to reply)
stijn goossens
2021-04-21 18:23:08 UTC
Permalink
Hello,

I'm trying to make a c_block in xcos (scilab 6.1.0) to communicate with a REST api.

I have a similar standalone c-program (but with a main function) running by building with two extra options: gcc hass.c -lcurl -ljson-c -o test (so -lcurl and -ljson-c).

I I try to create a c_block 4, I end up with this error.

I get errors like this
"/tmp/SCI_TMP_4905_6jDsU7"
Generate a loader file
Generate a Makefile
ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
ilib_gen_Make: Copy hass.c to TMPDIR
ilib_gen_Make: configure : Generate Makefile.
ilib_gen_Make: Modification of the Makefile in TMPDIR.
Running the Makefile
Generate a cleaner file
Link failed for dynamic library '/tmp/SCI_TMP_4905_6jDsU7/libhass.so'.
An error occurred: /tmp/SCI_TMP_4905_6jDsU7/libhass.so: undefined symbol: json_tokener_parse

this json_tokener_parse is part of #include <json-c/json.h>, so I assume that's why it doesn't find it.

1) is there any documentation or example programs hidden somewhere how to create such c_block4 function
(I don't even understand why to use c_block 4 or 3 or 2 or 1 ... )

2) Advice how to debug this type of blocks. I think for example I need to be able to tell this block to use json-c and libcurl ... but have no idea how to do so.

thanks
stijn goossens
2021-04-24 14:21:17 UTC
Permalink
I've tried something more simple:
1) copied the c function from https://github.com/scilab/scilab/blob/master/scilab/modules/scicos_blocks/src/c/absolute_value.c
2) changed the name from the .c file and name of the void function (fubar.c and void fubar )
3) used the ilib_for_link command and included the folder corresponding with https://github.com/scilab/scilab/tree/master/scilab/modules/scicos_blocks/includes in the arguments
ibn=ilib_for_link('fubar','fubar.c',[],'c','','loader.sce','','','-I /home/xxx/Projects/scilab/scilab/modules/scicos_blocks/includes','','')
Generate a loader file
Generate a Makefile
ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
ilib_gen_Make: Copy fubar.c to TMPDIR
ilib_gen_Make: configure : Generate Makefile.
ilib_gen_Make: Modification of the Makefile in TMPDIR.
Running the Makefile
Generate a cleaner file
ibn =

"libfubar.so"

4) create an xcos model using a generic_block3 and fill in fubar as " simulation function" in the arguments
This leads to the error:
" Initialisation problem:
scicosim : unknown block : fubar"

I don't seem to figure out how this importing of c-functions works ...
Loading...