Problem with the compilation and linking of c-code

Zoltán Magyar xmagyarz at gmail.com
Sun Nov 21 21:31:06 CET 2010


Greetings!
I would like to create an xcos block from a c-code, but I have problems 
with the compilation and the linking of the code.

(content of "myfunction.c")

#include "scicos_block4.h"

#define myIN        ((GetRealInPortPtrs(blk, (0) + 1))[(0)])
#define myOUT        ((GetRealOutPortPtrs(blk, (0) + 1))[(0)])

typedef struct {
     double variable;
} my_struct;

void myfunction(scicos_block *blk, int flag) {
     my_struct *ptr;

     switch (flag) {

         case 4: //Initialization:
               if ((*(blk->work) = 
(my_struct*)scicos_malloc(sizeof(my_struct))) == NULL) {
                 set_block_error(-16);
                 return;
             }

             ptr = *(blk->work);
             ptr->variable = 0;
             break;

         case 1: //OutputUpdate:
             ptr = *(blk->work);
             myOUT = myIN + ptr->variable;
             ptr->variable++;
             break;

         case 5: //Ending:
             scicos_free(*(blk->work));
             break;
     }
}

In Scilab I type ilib_for_link():

-->ilib_for_link('myfunction','myfunction.o',[],'c','Makelib','loader.sce','','',''); 

    Generate a loader file
    Generate a Makefile
    ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
    ilib_gen_Make: Copy myfunction.c~ to TMPDIR
    ilib_gen_Make: Copy myfunction.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

-->

then when I try to execute the loader I get the next error:
-->exec loader.sce

-->// This file is released into the public domain

-->// Generated by builder.sce : Please, do not edit this file

-->//


-->myfunction_path = get_absolute_file_path('loader.sce');


-->// ulink previous function with same name

-->[bOK,ilib] = c_link('myfunction');if (bOK) then ulink(ilib),end

-->link(myfunction_path+'libmyfunction'+getdynlibext(),['myfunction'],'c');
Link failed for dynamic library 
'/home/mzolee/Plocha/xcos_projects/try2/libmyfunction.so'.
An error occurred: 
/home/mzolee/Plocha/xcos_projects/try2/libmyfunction.so: undefined 
symbol: set_block_error
link(myfunction_path+'libmyfunction'+getdynlibext(),['myfunction'],'c');
                                                                         
!--error 236
link: The shared archive was not loaded: (null)
at line       9 of exec file called by :
exec loader.sce

I did the same thing in Scilab-5.1.1 and it worked, but in Scilab-5.2.1 
or in 5.2.2 i get the error as shown above.
Thanks for your help.
Zoltán

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20101121/fe3d46b4/attachment.htm>


More information about the users mailing list