我正在关注rails教程上的教程,并且在第三章(静态页面)上。当我尝试bundle install
立即执行清单 3.1 下的操作时,该命令会抛出一条错误消息,指示链接失败。错误片段如下所示:
Using bundler (1.2.1)
Using nokogiri (1.5.5)
Installing ffi (1.1.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby18 extconf.rb
checking for ffi_call() in -lffi... yes checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
checking for rb_thread_blocking_region()... no
checking for ruby_native_thread_p()... no
checking for rb_thread_call_with_gvl()... no creating extconf.h
creating Makefile
...
...
...
x86_64-pc-linux-gnu-gcc -I. -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"extconf.h\" -fPIC -O2 -pipe -fno-strict-aliasing -fPIC -I/usr/lib64/libffi-3.0.10/include -c LastError.c x86_64-pc-linux-gnu-gcc -shared -o ffi_c.so FunctionInfo.o MemoryPointer.o MethodHandle.o Platform.o Function.o LongDouble.o StructLayout.o StructByValue.o Struct.o Variadic.o ClosurePool.o Type.o Types.o ArrayType.o DynamicLibrary.o Thread.o Call.o Buffer.o StructByReference.o AbstractMemory.o ffi.o MappedType.o Pointer.o DataConverter.o LastError.o -L. -L/usr/lib64 -Wl,-R/usr/lib64 -L.-Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined -Wl,-R -Wl,/usr/lib64 -L/usr/lib64 -lruby18 -lffi -lffi -lrt -ldl -lcrypt -lm -lc
Thread.o: In function `rbffi_thread_blocking_region':
Thread.c:(.text+0xd0): undefined reference to `pthread_create'
Thread.c:(.text+0x106): undefined reference to `pthread_join'
Thread.o: In function `cleanup_blocking_thread': Thread.c:(.text+0x239): undefined reference to `pthread_kill'
Thread.o: In function `rbffi_blocking_thread': Thread.c:(.text+0x271): undefined reference to `pthread_testcancel' collect2: ld returned 1 exit status make: *** [ffi_c.so] Error 1
Gem files will remain installed in /home/user/.gem/gems/ffi-1.1.5 for inspection.
Results logged to /home/user/.gem/gems/ffi-1.1.5/ext/ffi_c/gem_make.out
An error occurred while installing ffi (1.1.5), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.1.5'` succeeds before bundling.
据我所知,这很容易通过为 pthread (-lpthread) 添加正确的库来解决。但我的问题是,我在哪里添加这个?我在 MAC OS X 上看到了很多解决这个问题的问题,但对于 linux 却没有。任何帮助表示赞赏。