[squeak-dev] Building a linux/Pi library to call via FFI

tim Rowledge tim at rowledge.org
Wed Sep 9 18:17:08 UTC 2015


I’m trying - and so far failing - to do what should surely be a very simple thing. This isn’t a new situation…
especially on unix.

I have a single C file with just two functions. I have a matching H file. I want to make them into a dynamic library that I can call via FFI. This really shouldn’t be rocket science stuff!

So far I can
a) compile the C file (well duh)
b) link it as a shared library
c) install it in /usr/local/lib (next to another library that I can use from FFI already, so I know the path gets looked at)
d) set the permissions to match the working library
e) use from a simple C program to prove it works

However, all I get from squeak is an error that the external module is not found. I’ll take a look with a debug vm but I’d  be very happy to hear that I’m forgetting some trivial flag or incantation that can short-circuit the ‘fun’ of using gdb.

Here is the code and makefile -
https://copy.com/DGDbpJM4wnHQrDUG

What I’ve been doing to build & try is
make clean
make 
sudo install -m 0755 libmadgwickIMU..s0.1 /usr/local/lib/libmadgwickIMU.so.1
sudo ln -sf /usr/local/lib/libmadgwickIMU.so.1 /usr/local/lib/libmadwickIMU.so
sudo ldconfig
gcc -Wall -o testing testing.c -lmadwickIMU
./testing

‘testing’ seem to do the right thing. Going into squeak (cog/spur/pi) and trying a method like -
invSqrt: floatval
#<cdecl: float ‘invSqrt’ (float) module: ‘madgwickIMU’>
^self externalCallFailed
- just gives me the not found module error.

I’ve restarted squeak after building the lib, I’ve opened a new terminal after building the lib (just in case there’s some stupid path-exporting nonsense I don’t understand etc) and I’ve made sure to smile only on the left side. What on earth am I forgetting?

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Useful Latin Phrases:- Braccae illae virides cum subucula rosea et tunica Caledonia-quam elenganter concinnatur! = Those green pants go so well with that pink shirt and the plaid jacket!




More information about the Squeak-dev mailing list