Link with Scilab

classic Classic list List threaded Threaded
10 messages Options
Romain Cotte Romain Cotte
Reply | Threaded
Open this post in threaded view
|

Link with Scilab






Hello,

I would like to make a link with fortran code but which needs a C
library. I can obtain an executable a.out by this way :

gcc -c lib1.c lib2.f subroutine.f

I tried : l=ilib_for_link('rosen',['lib1.o','lib2.o','subroutine.o'],
[],'f',PWD+'/Makefile');
(gcc -c lib1.c -o lib1.o)
but i get errors which are only warnings with gcc :

!adStack.c:351: warning: format '%li' expects type 'long int', but
argument 4 has type 'int'  !
!adBuffer.c:41: error: expected specifier-qualifier-list before
'longint'                     !
!adBuffer.c:89: error: expected specifier-qualifier-list before
'longint'                     !
!adBuffer.c:115: error: expected specifier-qualifier-list before
'longint'                    !
!adBuffer.c:118: error: extra brace group at end of
initializer                               !
!adBuffer.c:118: error: (near initialization for
'adi8fbuf_')                                 !
!adBuffer.c:118: warning: excess elements in struct
initializer                               !
!adBuffer.c:118: warning: (near initialization for
'adi8fbuf_')                               !
!adBuffer.c:118: warning: (near initialization for
'adi8fbuf_')                               !
!adBuffer.c:151: error: expected specifier-qualifier-list before
'longint'                    !
!adBuffer.c:152: warning: excess elements in struct
initializer                               !
!adBuffer.c:152: warning: (near initialization for
'mmcomtraffic_')                           !
!adBuffer.c:152: warning: excess elements in struct
initializer                               !
!adBuffer.c:152: warning: (near initialization for
'mmcomtraffic_')                           !
!adBuffer.c:404: error: expected ')' before '*'
token                                         !
!adBuffer.c:427: error: expected ')' before '*'
token                                         !
!adBuffer.c:451: error: expected ')' before '*'
token                                         !
!adBuffer.c: In function
'addftraffic_':                                                      !
!adBuffer.c:894: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.c:907: error: 'struct mmcomtraffic_1_' has no member named
'mmftrafficm'            !
!adBuffer.c:908: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.c: In function
'printtraffic_':                                                     !
!adBuffer.c:924: error: 'longint' undeclared (first use in this
function)                     !
!adBuffer.c:924: error: (Each undeclared identifier is reported only
once                     !
!adBuffer.c:924: error: for each function it appears
in.)                                     !
!adBuffer.c:924: error: expected ';' before
'i8__1'                                           !
!adBuffer.c:939: error: 'struct mmcomtraffic_1_' has no member named
'mmftrafficm'            !
!adBuffer.c:942: error: 'i8__1' undeclared (first use in this
function)                       !
!adBuffer.c:942: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.c: In function
'printbuffertop_':                                                   !
!adBuffer.c:991: error: 'struct adi8fbuf_1_' has no member named
'adi8ibuf'                   !
!adBuffer.c: In function
'smallstacksize_':                                                   !
!adBuffer.c:1043: error: 'struct adi8fbuf_1_' has no member named
'adi8ibuf'

I wonder if it's possible to modify options for compilation or if
there is an another way.
Makefile :

OBJS =  rosenf.o
OTHERLIBS =
LIBRARY = librosenf
include $(SCIDIR)/Makefile.incl
CFLAGS = $(CC_OPTIONS)
FFLAGS = $(FC_OPTIONS)
EXTRA_LDFLAGS =
include $(SCIDIR)/config/Makeso.incl

version scilab 5.1.1

sylvestre sylvestre
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab

Le mardi 08 septembre 2009 à 18:21 -0400, Romain Cotte a écrit :

>
>
>
>
> Hello,
>
> I would like to make a link with fortran code but which needs a C
> library. I can obtain an executable a.out by this way :
>
> gcc -c lib1.c lib2.f subroutine.f
>
> I tried : l=ilib_for_link('rosen',['lib1.o','lib2.o','subroutine.o'],
> [],'f',PWD+'/Makefile');
> (gcc -c lib1.c -o lib1.o)
If you are using scilab >= 5.0, please use actual file name (.c instead
of .o).
Makefile are no longer necessary (they are generated on the fly).

> but i get errors which are only warnings with gcc :
>
> !adStack.c:351: warning: format '%li' expects type 'long int', but
> argument 4 has type 'int'  !
> !adBuffer.c:41: error: expected specifier-qualifier-list before
> 'longint'                     !
Looks like a missing include.
By the way, I cannot see any references to adBuffer.c or adStack.c in
your command upper (ilib_for_link).

> I wonder if it's possible to modify options for compilation or if
> there is an another way.
> Makefile :
>
> OBJS =  rosenf.o
> OTHERLIBS =
> LIBRARY = librosenf
> include $(SCIDIR)/Makefile.incl
> CFLAGS = $(CC_OPTIONS)
> FFLAGS = $(FC_OPTIONS)
> EXTRA_LDFLAGS =
> include $(SCIDIR)/config/Makeso.incl
Where did you find this makefile ?
This way of using dynamic link has been deprecated a while ago.

Sylvestre

--
-------------------------
Sylvestre Ledru
-------------------------
The Scilab Consortium
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105
78153 Le Chesnay Cedex
France


Romain Cotte Romain Cotte
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab


Thanks for help.
It was only to explain in general case but actually, here, lib1.o is for
adStack.o, lib2.o for adBuffer.o, subroutine.o for rosenf_b.o.


I also tried to call
l=ilib_for_link('rosenf',['adStack.c','adBuffer.f','rosenf_b.f'],[],'f');


It uses the right Makefile in TMPDIR however i have the same errors and moreover
:


!perl: warning: Setting locale failed.
!perl: warning: Please check that your locale settings:
! LANGUAGE = "",
! LC_ALL = (unset),
! LC_NUMERIC = "C",
! LC_MESSAGES = "fr_CA",
! LANG = "C"
!    are supported and installed on your system.
!perl: warning: Falling back to the standard locale ("C").
!   characters:
!   BLOCK DATA characters:
!   pushcharacter:
!perl: warning: Setting locale failed.
!perl: warning: Please check that your locale settings:
! LANGUAGE = "",
! LC_ALL = (unset),
! LC_MESSAGES = "fr_CA",
! LC_NUMERIC = "C",
! LANG = "C"
!    are supported and installed on your system.
!perl: warning: Falling back to the standard locale ("C").
!   lookcharacter:
!   popcharacter:







Quoting Sylvestre Ledru <[hidden email]>:

> Le mardi 08 septembre 2009 à 18:21 -0400, Romain Cotte a écrit :
> >
> >
> >
> >
> > Hello,
> >
> > I would like to make a link with fortran code but which needs a C
> > library. I can obtain an executable a.out by this way :
> >
> > gcc -c lib1.c lib2.f subroutine.f
> >
> > I tried : l=ilib_for_link('rosen',['lib1.o','lib2.o','subroutine.o'],
> > [],'f',PWD+'/Makefile');
> > (gcc -c lib1.c -o lib1.o)
> If you are using scilab >= 5.0, please use actual file name (.c instead
> of .o).
> Makefile are no longer necessary (they are generated on the fly).
>
> > but i get errors which are only warnings with gcc :
> >
> > !adStack.c:351: warning: format '%li' expects type 'long int', but
> > argument 4 has type 'int'  !
> > !adBuffer.c:41: error: expected specifier-qualifier-list before
> > 'longint'                     !
> Looks like a missing include.
> By the way, I cannot see any references to adBuffer.c or adStack.c in
> your command upper (ilib_for_link).
>
> > I wonder if it's possible to modify options for compilation or if
> > there is an another way.
> > Makefile :
> >
> > OBJS =  rosenf.o
> > OTHERLIBS =
> > LIBRARY = librosenf
> > include $(SCIDIR)/Makefile.incl
> > CFLAGS = $(CC_OPTIONS)
> > FFLAGS = $(FC_OPTIONS)
> > EXTRA_LDFLAGS =
> > include $(SCIDIR)/config/Makeso.incl
> Where did you find this makefile ?
> This way of using dynamic link has been deprecated a while ago.
>
> Sylvestre
>
> --
> -------------------------
> Sylvestre Ledru
> -------------------------
> The Scilab Consortium
> Digiteo
> Domaine de Voluceau
> Rocquencourt - B.P. 105
> 78153 Le Chesnay Cedex
> France
>
>
>




sylvestre sylvestre
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab

Le mercredi 09 septembre 2009 à 12:53 -0400, Romain Cotte a écrit :
> Thanks for help.
You are welcome.

> It was only to explain in general case but actually, here, lib1.o is for
> adStack.o, lib2.o for adBuffer.o, subroutine.o for rosenf_b.o.
OK, but it is much easier for us to help you if we have the actual commands.

>
> I also tried to call
> l=ilib_for_link('rosenf',['adStack.c','adBuffer.f','rosenf_b.f'],[],'f');
>
>
> It uses the right Makefile in TMPDIR however i have the same errors and moreover
It is just some warnings about localization. No big deal.
Do you have any real error messages ?

Thanks
Sylvestre

--
-------------------------
Sylvestre Ledru
-------------------------
The Scilab Consortium
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105
78153 Le Chesnay Cedex
France


Romain Cotte Romain Cotte
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab


> > It uses the right Makefile in TMPDIR however i have the same errors and
> > moreover
> It is just some warnings about localization. No big deal.
> Do you have any real error messages ?

Yes, the same. (It works correctly with gcc)



!adBuffer.f:27: error: expected specifier-qualifier-list before 'longint'      
             !
!adBuffer.f:75: error: expected specifier-qualifier-list before 'longint'      
             !
!adBuffer.f:101: error: expected specifier-qualifier-list before 'longint'      
             !
!adBuffer.f:104: error: extra brace group at end of initializer                
             !
!adBuffer.f:104: error: (near initialization for 'adi8fbuf_')                  
             !
!adBuffer.f:104: warning: excess elements in struct initializer                
             !
!adBuffer.f:104: warning: (near initialization for 'adi8fbuf_')                
             !
!adBuffer.f:104: warning: excess elements in struct initializer                
             !
!adBuffer.f:104: warning: (near initialization for 'adi8fbuf_')                
             !
!adBuffer.f:104: warning: excess elements in struct initializer                
             !
!adBuffer.f:104: warning: (near initialization for 'adi8fbuf_')                
             !
!adBuffer.f:104: warning: excess elements in struct initializer                
             !
!adBuffer.f:104: warning: (near initialization for 'adi8fbuf_')                
             !
!adBuffer.f:137: error: expected specifier-qualifier-list before 'longint'      
             !
!adBuffer.f:138: warning: excess elements in struct initializer                
             !
!adBuffer.f:138: warning: (near initialization for 'mmcomtraffic_')            
             !
!adBuffer.f:138: warning: excess elements in struct initializer                
             !
!adBuffer.f:138: warning: (near initialization for 'mmcomtraffic_')            
             !
!adBuffer.f:245: error: expected ')' before '*' token                          
             !
!adBuffer.f:276: error: expected ')' before '*' token                          
             !
!adBuffer.f:299: error: expected ')' before '*' token                          
             !
!adBuffer.f: In function 'addftraffic_':                                        
             !
!adBuffer.f:728: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:729: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:730: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:731: error: 'struct mmcomtraffic_1_' has no member named
'mmftrafficm'            !
!adBuffer.f:732: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:737: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:738: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f:739: error: 'struct mmcomtraffic_1_' has no member named
'mmftrafficm'            !
!adBuffer.f:740: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f: In function 'printtraffic_':                                      
             !
!adBuffer.f:756: error: 'longint' undeclared (first use in this function)      
             !
!adBuffer.f:756: error: (Each undeclared identifier is reported only once      
             !
!adBuffer.f:756: error: for each function it appears in.)                      
             !
!adBuffer.f:756: error: expected ';' before 'i8__1'                            
             !
!adBuffer.f:753: error: 'struct mmcomtraffic_1_' has no member named
'mmftrafficm'            !
!adBuffer.f:753: error: 'i8__1' undeclared (first use in this function)        
             !
!adBuffer.f:753: error: 'struct mmcomtraffic_1_' has no member named
'mmftraffic'             !
!adBuffer.f: In function 'printbuffertop_':                                    
             !
!adBuffer.f:832: error: 'struct adi8fbuf_1_' has no member named 'adi8ibuf'    
             !
!adBuffer.f: In function 'smallstacksize_':                                    
             !
!adBuffer.f:917: error: 'struct adi8fbuf_1_' has no member named 'adi8ibuf'    
             !
!/usr/bin/f77: aborting compilation                                            
             !
!make: *** [adBuffer.lo] Error 1                                                
             !

sylvestre sylvestre
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab

Le jeudi 10 septembre 2009 à 11:19 -0400, Romain Cotte a écrit :
> > > It uses the right Makefile in TMPDIR however i have the same errors and
> > > moreover
> > It is just some warnings about localization. No big deal.
> > Do you have any real error messages ?
>
> Yes, the same. (It works correctly with gcc)
It is possible to see the code ?

Thanks
Sylvestre



Romain Cotte Romain Cotte
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab


> It is possible to see the code ?
>


Sure. Compilation with gfortran in fact :
gfortran adStack.c adBuffer.f rosenf_b.f test.f



Code.tar.gz (10K) Download Attachment
sylvestre sylvestre
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab

Le jeudi 10 septembre 2009 à 13:13 -0400, Romain Cotte a écrit :
> > It is possible to see the code ?
> >
>
>
> Sure. Compilation with gfortran in fact :
> gfortran adStack.c adBuffer.f rosenf_b.f test.f
Thanks for the example.
However, tested with Scilab 5.1.1, it works fine for me.


-->l=ilib_for_link('rosenf',['adStack.c','adBuffer.f','rosenf_b.f'],[],'f');
   Generate a loader file
   Generate a Makefile
   ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to
TMPDIR
   ilib_gen_Make: Copy adStack.c to TMPDIR
   ilib_gen_Make: Copy adBuffer.f to TMPDIR
   ilib_gen_Make: Copy rosenf_b.f to TMPDIR
   ilib_gen_Make: configure : Generate Makefile.
   ilib_gen_Make: Modification of the Makefile in TMPDIR.
   Running the Makefile

-->

I guess it is more related to your computer.

A way to be able to fix it more easily is:
* in Scilab, type
disp(TMPDIR)
* in a terminal, go in this directory
* when you had an error, you should have get a (long) command line
starting with make CFLAGS=...
copy and paste this command in the TMPDIR directory
you may get some better feedbacks which will explain you what is the
actual error.

Sylvestre


>
--
-------------------------
Sylvestre Ledru
-------------------------
The Scilab Consortium
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105
78153 Le Chesnay Cedex
France


Romain Cotte Romain Cotte
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab




> it works fine for me.

> -->l=ilib_for_link('rosenf',['adStack.c','adBuffer.f','rosenf_b.f'],[],'f');

Thanks,
I changed my fortran compiler and ilib_for_link seems to work. However, i can't
link l.

link(l,'rosenf','f')
Link failed for dynamic library 'librosenf.so'.
An error occurred: librosenf.so: Ne peut ouvrir le fichier d'objet partagé:
Aucun fichier ou dossier de ce type
                       !--error 236
link: The shared archive was not loaded: (null)

sylvestre sylvestre
Reply | Threaded
Open this post in threaded view
|

Re: Link with Scilab

Le lundi 14 septembre 2009 à 13:47 -0400, Romain Cotte a écrit :

>
>
> > it works fine for me.
>
> > -->l=ilib_for_link('rosenf',['adStack.c','adBuffer.f','rosenf_b.f'],[],'f');
>
> Thanks,
> I changed my fortran compiler and ilib_for_link seems to work. However, i can't
> link l.
>
> link(l,'rosenf','f')
> Link failed for dynamic library 'librosenf.so'.
> An error occurred: librosenf.so: Ne peut ouvrir le fichier d'objet partagé:
> Aucun fichier ou dossier de ce type
>                        !--error 236
> link: The shared archive was not loaded: (null)
--
-------------------------
Sylvestre Ledru
-------------------------
The Scilab Consortium
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105
78153 Le Chesnay Cedex
France