I am trying to use the Chipmunk physics library in Racket using the FFI that it provides. However, I am currently having issues with actually getting the FFI to find the functions in the Chipmunk library, even though it seems to load the library correctly.
I am using the most recent version of Chipmunk (6.1.1) built on Windows 8 with Visual Studio 2008. I have the "CHIPMUNK_FFI" flag set so that the chipmunk_ffi.h file is loaded. I am building the code under the Release DLL configuration with "Multi-Threaded DLL" and "Build as a dll" optoins being used. The Racket code I am using is as follows:
#lang scheme
(require ffi/unsafe
ffi/unsafe/define)
(define chipmunk (ffi-lib "./chipmunk"))
(define-ffi-definer define-chipmunk chipmunk)
(define _cpFloat _double)
(define cpFloat? real?)
(define _cpDataPointer _pointer)
(define _size_t _ulong)
(define _cpHashValue _size_t)
(define-cstruct _cpVect
([x _cpFloat]
[y _cpFloat]))
(define cpv
(get-ffi-obj "cpvadd" chipmunk (_fun _cpVect _cpVect -> _cpVect)))
And I am getting the error:
ffi-obj: couldn't get "cpvadd" from "chipmunk.dll" (The specified procedure could not be found.; errno=127)
=== context ===
C:\Program Files (x86)\Racket\collects\ffi\unsafe.rkt:180:2: get-ffi-obj*
C:\Users\me.000\AppData\Roaming\Racket\planet\300\5.2.1\cache\jaymccarthy\chipmunk.plt\1\0\chipmunk-ffi-new.ss: [running body]
C:\Users\me.000\AppData\Roaming\Racket\planet\300\5.2.1\cache\jaymccarthy\chipmunk.plt\1\0\chipmunk-new.rkt: [traversing imports]
C:\Users\me.000\AppData\Roaming\Racket\planet\300\5.2.1\cache\jaymccarthy\chipmunk.plt\1\0\main.rkt: [traversing imports]
C:\Users\me.000\Dropbox\Code\workspace-racket\learning\main.rkt: [traversing imports]
Let me know if you need any further information. I would really appreciate some help with this.
Some functions (such as cpvadd
are exported as _cpvadd
).
See http://code.google.com/p/chipmunk-physics/source/browse/trunk/include/chipmunk/chipmunk_ffi.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With