Using FFI to call a MacOs System function

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

Using FFI to call a MacOs System function

DavidWilson
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's),  
and I'm trying to use FFI to access an MacOs system function:

apiKLGetKeyboardLayoutCount
     < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module:  
'keyboards'>
     ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say  
the OS-module "keyboards" can't be found.
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/ 
library/documentation/Carbon/Reference/KeyboardLayoutServices/
Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).

I'm not sure if I'm using FFI correctly, do I have to somehow include  
the external library in the Pharo VM?
Can anyone help?

I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

Mariano Martinez Peck


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

Mariano Martinez Peck
BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

DavidWilson
Hi Mariano

Thanks for the tips.
I haven't had time to follow these up, I should do in the next few days, and I'll post a reply in the forum.

Thanks

David



On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

DavidWilson
In reply to this post by Mariano Martinez Peck
Hi Mariano

Thanks for the tips, you got me on the right track. Some trial and lots of error got me to a solution.

In order to use MacOs system calls you have to:
1) identify the function you want to use e.g. KLGetKeyboardLayoutCount
2) find out what header file this is defined in. here it's "Keyboards.h" in the Framework "Carbon/Carbon.h"
So far it's easy from the Apple documentation

3) find out which Bundle this is in. I used Finder to find out where Keyboards.h is used, it's used in HIToolbox.framework
4) find the actual compiled framework, on my system it's at:
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
5) I placed a copy of this file in the Pharo bundle at:  Pharo-1.0.app/Contents/Resources/HIToolbox

An the call looks like:

apiKLGetKeyboardLayoutCount
    < cdecl: ulong 'KLGetKeyboardLayoutCount' (void) module: 'HIToolbox'>   
    ^ self externalCallFailed. 

I tried a link to the bundle, that didn't work.
Probably the correct way to do this is to change Pharos RES path (in Pharo.sh) to include the a pointer to HIToolbox executable.
I may try that if I go further with this than a prototype.

Cheers

David





On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

Mariano Martinez Peck


On Fri, May 14, 2010 at 7:04 PM, David Wilson <[hidden email]> wrote:
Hi Mariano

Thanks for the tips, you got me on the right track. Some trial and lots of error got me to a solution.


Hi David. I am glad it worked.
 
In order to use MacOs system calls you have to:
1) identify the function you want to use e.g. KLGetKeyboardLayoutCount
2) find out what header file this is defined in. here it's "Keyboards.h" in the Framework "Carbon/Carbon.h"
So far it's easy from the Apple documentation

3) find out which Bundle this is in. I used Finder to find out where Keyboards.h is used, it's used in HIToolbox.framework
4) find the actual compiled framework, on my system it's at:
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
5) I placed a copy of this file in the Pharo bundle at:  Pharo-1.0.app/Contents/Resources/HIToolbox

An the call looks like:

apiKLGetKeyboardLayoutCount
    < cdecl: ulong 'KLGetKeyboardLayoutCount' (void) module: 'HIToolbox'>   
    ^ self externalCallFailed. 

I tried a link to the bundle, that didn't work.
Probably the correct way to do this is to change Pharos RES path (in Pharo.sh) to include the a pointer to HIToolbox executable.
I may try that if I go further with this than a prototype.


Let us know your progress. Now...would you like to help us and document all this in http://book.seaside.st/  ?
We need to write all this down. Image the poor guy that comes after you...imagine if someone already had this problem and you would have found such info...wouldn't that be cool ?   Don't worry for the English neither to the text. It doesn't need to be perfect. This is continuous...we first write, and then the community will give feedback, correct it, complete it, etc...

If you want to join, please let us know and we generate a user for you.

Cheers

Mariano

Cheers

David





On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

Mariano Martinez Peck


Let us know your progress. Now...would you like to help us and document all this in http://book.seaside.st/  ?


Sorry I mean http://book.pharo-project.org/     ;)  too many books


 
We need to write all this down. Image the poor guy that comes after you...imagine if someone already had this problem and you would have found such info...wouldn't that be cool ?   Don't worry for the English neither to the text. It doesn't need to be perfect. This is continuous...we first write, and then the community will give feedback, correct it, complete it, etc...

If you want to join, please let us know and we generate a user for you.

Cheers

Mariano

Cheers

David





On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users




_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

DavidWilson
Hi Mariano

I now see that my solution (yesterday) was a hack.
If I do something with this (ie gain real experience) then I'll look at working on the documentation.

Cheers

David


On 14 May, 2010, at 20:16, Mariano Martinez Peck wrote:



Let us know your progress. Now...would you like to help us and document all this in http://book.seaside.st/  ?


Sorry I mean http://book.pharo-project.org/     ;)  too many books


 
We need to write all this down. Image the poor guy that comes after you...imagine if someone already had this problem and you would have found such info...wouldn't that be cool ?   Don't worry for the English neither to the text. It doesn't need to be perfect. This is continuous...we first write, and then the community will give feedback, correct it, complete it, etc...

If you want to join, please let us know and we generate a user for you.

Cheers

Mariano

Cheers

David





On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI to call a MacOs System function

Mariano Martinez Peck


On Sat, May 15, 2010 at 8:42 PM, David Wilson <[hidden email]> wrote:
Hi Mariano

I now see that my solution (yesterday) was a hack.

hahhaha I though that when I read it ;) 
But as I don't know how it is, I didn't say anything.
 
If I do something with this (ie gain real experience) then I'll look at working on the documentation.


Excellent!

 
Cheers

David


On 14 May, 2010, at 20:16, Mariano Martinez Peck wrote:



Let us know your progress. Now...would you like to help us and document all this in http://book.seaside.st/  ?


Sorry I mean http://book.pharo-project.org/     ;)  too many books


 
We need to write all this down. Image the poor guy that comes after you...imagine if someone already had this problem and you would have found such info...wouldn't that be cool ?   Don't worry for the English neither to the text. It doesn't need to be perfect. This is continuous...we first write, and then the community will give feedback, correct it, complete it, etc...

If you want to join, please let us know and we generate a user for you.

Cheers

Mariano

Cheers

David





On 05 May, 2010, at 23:15, Mariano Martinez Peck wrote:

BTW....keyboards seems to be a .h  (a header) , but not a library...at least in my mac

Do you have also the library ?  I am still newbie with the Mac OS :(

Cheers

mariano

On Wed, May 5, 2010 at 11:10 PM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, May 4, 2010 at 4:46 PM, David Wilson <[hidden email]> wrote:
Hi

I'm new to Pharo (although I was a Smalltalk programmer in the 90's), and I'm trying to use FFI to access an MacOs system function:


Hi and welcome!
 
apiKLGetKeyboardLayoutCount
   < cdecl: ulong 'KLGetKeyboardLayoutCount' (void)  module: 'keyboards'>
   ^ self externalCallFailed.

I get an error "'Unable to find function address'" which seems to say the OS-module "keyboards" can't be found.

Exactly. That's the problem.
 
I can't figure out what the address should be.
The function is defined here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/KeyboardLayoutServices/Reference/reference.html
(yes, it's deprecated, I have a very old mac runnning 10.4).


But you see the library in your computer, isn't it ? I mean, it is there, but FFI doesn't find it ?

 
I'm not sure if I'm using FFI correctly, do I have to somehow include the external library in the Pharo VM?

No, you shouldn't need to do that. However, you can try to put them there just to see if that's the problem. I think that at some point (depends on an order) the library is searched in the same place where you are calling from. So, yes, do a test, but just a test. It should work without doing that.

How did you install FFI ?  Which Pharo VM and image versions are you using ?

Can anyone help?


I would like too, but I don't have such library.

I developed a wrapper for a Clibrary called OpenDBX using FFI. In our website, some people experimented similar problems.
Please take a look to the title "Problems with Mac OS:"  of the following link:

http://www.squeakdbx.org/Compiling%20and%20installing%20OpenDBX
 
I also cc'ed people that can help you.

Cheers

Mariano


I'm looked for FFI examples, but don't find anything helpful.

David


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users