Missing ffi_prep_closure for ffi-1.13.1 gem

Jialiang Liang
1 min readSep 3, 2020

--

Today, I tried to setup a project that is using bootstrap gem, which got dependency for ffi. And when I tried to do bundle install , I got following error:

Function.c:852:17: error: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ffiStatus = ffi_prep_closure_loc(code, &fnInfo->ffi_cif, callback_invoke, closure, code);
^
Function.c:852:17: note: did you mean 'ffi_prep_closure'?
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ffi/ffi.h:269:1: note: 'ffi_prep_closure' declared here
ffi_prep_closure(
^
1 error generated.
make: *** [Function.o] Error 1
make failed, exit code 2

Did a quick search online, and found a temporary solution from this issue:

gem install ffi -- --disable-system-libffi

Turns out ffi-1.13.1 is using ffi_prep_closure_loc() and system-libffi for Mac doesn’t have that function.

--

--