<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <div class="moz-text-flowed" style="font-family: -moz-fixed;
      font-size: 13px;" lang="x-central-euro">Greetings!
      <br>
      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.
      <br>
      <br>
      (content of "myfunction.c")
      <br>
      <br>
      #include "scicos_block4.h"
      <br>
      <br>
      #define myIN        ((GetRealInPortPtrs(blk, (0) + 1))[(0)])
      <br>
      #define myOUT        ((GetRealOutPortPtrs(blk, (0) + 1))[(0)])
      <br>
      <br>
      typedef struct {
      <br>
          double variable;
      <br>
      } my_struct;
      <br>
      <br>
      void myfunction(scicos_block *blk, int flag) {
      <br>
          my_struct *ptr;
      <br>
      <br>
          switch (flag) {
      <br>
      <br>
              case 4: //Initialization:
      <br>
                    if ((*(blk->work) =
      (my_struct*)scicos_malloc(sizeof(my_struct))) == NULL) {
      <br>
                      set_block_error(-16);
      <br>
                      return;
      <br>
                  }
      <br>
      <br>
                  ptr = *(blk->work);
      <br>
                  ptr->variable = 0;
      <br>
                  break;
      <br>
      <br>
              case 1: //OutputUpdate:
      <br>
                  ptr = *(blk->work);
      <br>
                  myOUT = myIN + ptr->variable;
      <br>
                  ptr->variable++;
      <br>
                  break;
      <br>
      <br>
              case 5: //Ending:
      <br>
                  scicos_free(*(blk->work));
      <br>
                  break;
      <br>
          }
      <br>
      }
      <br>
      <br>
      In Scilab I type ilib_for_link():
      <br>
      <br>
-->ilib_for_link('myfunction','myfunction.o',[],'c','Makelib','loader.sce','','','');
      <br>
         Generate a loader file
      <br>
         Generate a Makefile
      <br>
         ilib_gen_Make: Copy compilation files (Makefile*, libtool...)
      to TMPDIR
      <br>
         ilib_gen_Make: Copy myfunction.c~ to TMPDIR
      <br>
         ilib_gen_Make: Copy myfunction.c to TMPDIR
      <br>
         ilib_gen_Make: configure : Generate Makefile.
      <br>
         ilib_gen_Make: Modification of the Makefile in TMPDIR.
      <br>
         Running the Makefile
      <br>
         Generate a cleaner file
      <br>
      <br>
      -->
      <br>
      <br>
      then when I try to execute the loader I get the next error:
      <br>
      -->exec loader.sce
      <br>
      <br>
      -->// This file is released into the public domain
      <br>
      <br>
      -->// Generated by builder.sce : Please, do not edit this file
      <br>
      <br>
      -->//
      <br>
      <br>
      <br>
      -->myfunction_path = get_absolute_file_path('loader.sce');
      <br>
      <br>
      <br>
      -->// ulink previous function with same name
      <br>
      <br>
      -->[bOK,ilib] = c_link('myfunction');if (bOK) then
      ulink(ilib),end
      <br>
      <br>
-->link(myfunction_path+'libmyfunction'+getdynlibext(),['myfunction'],'c');
      <br>
      Link failed for dynamic library
      '/home/mzolee/Plocha/xcos_projects/try2/libmyfunction.so'.
      <br>
      An error occurred:
      /home/mzolee/Plocha/xcos_projects/try2/libmyfunction.so: undefined
      symbol: set_block_error
      <br>
link(myfunction_path+'libmyfunction'+getdynlibext(),['myfunction'],'c');
      <br>
                                                                             
      !--error 236
      <br>
      link: The shared archive was not loaded: (null)
      <br>
      at line       9 of exec file called by :
      <br>
      exec loader.sce
      <br>
      <br>
      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.
      <br>
      Thanks for your help.
      <br>
      Zoltán
      <br>
      <br>
    </div>
  </body>
</html>