Subject: [ruby-ffi] Re: Install ffi on Mac gives trouble with asm insert |
From: Wayne Meissner |
Date: 7/23/12 5:27 PM |
To: ruby-ffi@googlegroups.com |
The problem: Installing ffi-1.1.0 on my Mac (system details below) producesoutput including this error message:---------$ gem install ffiBuilding native extensions. This could take a while...ERROR: Error installing ffi:ERROR: Failed to build gem native extension./Users/clarke/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for ffi_call() in -lffi... yeschecking for ffi_prep_closure()... yeschecking for ffi_raw_call()... yeschecking for ffi_prep_raw_closure()... yeschecking for rb_thread_blocking_region()... yeschecking for ruby_native_thread_p()... yeschecking for rb_thread_call_with_gvl()... yescreating extconf.hcreating Makefilemake[...]compiling MethodHandle.cMethodHandle.c:204: error: expected declaration specifiers or '...' before string constant[...]make: *** [MethodHandle.o] Error 1Gem files will remain installed in /Users/clarke/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.1.0 for inspection. Results logged to /Users/clarke/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.1.0/ext/ ffi_c/gem_make.out ---------Essentially the same error appeared with ffi-1.0.11. Given the line number,it seems that the asm() insert is being rejected.My system:Mac OX X 10.7.4 (Lion)Xcode 4.3.3gcc: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 ---------Here are two changes, either one of which seems to allow make to run in the ext directory.Both changes affect this line in ext/Makefile:CFLAGS = -fno-common -std=c99 -pedantic -Wall -fno-common -pipe -I/opt/local/lib/libffi-3.0.11/include $(ARCH_FLAG) First fix: remove -std=c99orSecond fix: replace -std=c99 with -std=gnu99Since I don't do much C programming on the Mac (and have never used asm in aC program), and since I'm totally new to Ruby, I offer these fixes more as guessesthan as firm suggestions. However, Googling turned up one or two unresolvedqueries about the same problem, so maybe I'm not alone?I'd be a little unhappy to try becoming my own ffi expert. Any chance of amore authoritative fix?