Use FFI with Linux / Ubuntu ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Use FFI with Linux / Ubuntu ?

bouchet vincent
Hello,

I'm  squeak newbie and I want to use a C DLL with FFI on Linux (I use the The Ubuntu Linux distribution).

    I have a function test which is written in a Linux C DLL. It works when I call it from an exe.
When I call it from my class I obtain the error message : "Error: unable to find function address"

---------------------------------------------------------------------
TestClass>>testLinux
    <cdecl: void 'test' (void) module: 'test.so'>
    ^self externalCallFailed
---------------------------------------------------------------------

I use FFI with windows for an C Windows DLL and it works correctly,  so is the FFI package works with Linux / Ubuntu ?


thanks,

Vincent

Reply | Threaded
Open this post in threaded view
|

Re: Use FFI with Linux / Ubuntu ?

Dave Hylands
Hi Vincent,

>  I'm  squeak newbie and I want to use a C DLL with FFI on Linux (I use the
> The Ubuntu Linux distribution).
>
>      I have a function test which is written in a Linux C DLL. It works when
> I call it from an exe.
>  When I call it from my class I obtain the error message : "Error: unable to
> find function address"

Just an off the wall guess, but is the diretory containing test.so
included in the environment variable LD_LIBRARY_:PATH?

> ---------------------------------------------------------------------
>  TestClass>>testLinux
>      <cdecl: void 'test' (void) module: 'test.so'>
>      ^self externalCallFailed
> ---------------------------------------------------------------------
>
>  I use FFI with windows for an C Windows DLL and it works correctly,  so is
> the FFI package works with Linux / Ubuntu ?

I'd be very interested to see your example. I'd like to interface i2c
to Squeak and to do so I would like to make some wrapper functions
available (the wrapper functions all eventually call ioctl, but that
doesn't seem to be availble to Squeak either).

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Reply | Threaded
Open this post in threaded view
|

Re: Use FFI with Linux / Ubuntu ?

bouchet vincent


2006/3/2, Dave Hylands <[hidden email]>:
Hi Vincent,

Hi Dave

>  I'm  squeak newbie and I want to use a C DLL with FFI on Linux (I use the
> The Ubuntu Linux distribution).
>
>      I have a function test which is written in a Linux C DLL. It works when
> I call it from an exe.
>  When I call it from my class I obtain the error message : "Error: unable to
> find function address"

Just an off the wall guess, but is the diretory containing test.so
included in the environment variable LD_LIBRARY_:PATH?

no, I test this and .... same problem, but when I put test.so in my home directory it's work... thanks, it's the good idea. (I'm really not accustomed to linux) 

> ---------------------------------------------------------------------
>  TestClass>>testLinux
>      <cdecl: void 'test' (void) module: 'test.so'>
>      ^self externalCallFailed
> ---------------------------------------------------------------------
>
>  I use FFI with windows for an C Windows DLL and it works correctly,  so is
> the FFI package works with Linux / Ubuntu ?

I'd be very interested to see your example. I'd like to interface i2c
to Squeak and to do so I would like to make some wrapper functions
available (the wrapper functions all eventually call ioctl, but that
doesn't seem to be availble to Squeak either).

I use "apicall" instead of "cdecl" and just put my dll in the same directory than squeak.
___________________________________
say: aString
<apicall: long '?play@@YAXPAD@Z' (char *) module:'Acces.dll'>
    ^self externalCallFailed
 ___________________________________

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/




Reply | Threaded
Open this post in threaded view
|

Re: Use FFI with Linux / Ubuntu ?

Andreas.Raab
In reply to this post by bouchet vincent
If it says "Error: unable to find function address" then your library
isn't compiled correctly, e.g., doesn't export the entry point
correctly. Two things to check:

1) Do you export the symbol properly?
2) Do you use a C++ compiler? (this would mangle the name)

Cheers,
   - Andreas

bouchet vincent wrote:

> Hello,
>
> I'm  squeak newbie and I want to use a C DLL with FFI on Linux (I use
> the The Ubuntu Linux distribution).
>
>     I have a function test which is written in a Linux C DLL. It works
> when I call it from an exe.
> When I call it from my class I obtain the error message : "Error: unable
> to find function address"
>
> ---------------------------------------------------------------------
> TestClass>>testLinux
>     <cdecl: void 'test' (void) module: 'test.so'>
>     ^self externalCallFailed
> ---------------------------------------------------------------------
>
> I use FFI with windows for an C Windows DLL and it works correctly,  so
> is the FFI package works with Linux / Ubuntu ?
>
>
> thanks,
>
> Vincent
>
>
> ------------------------------------------------------------------------
>
>