Tag: ffi

安装ffi ruby​​ gem时无法找到ffi.h

Ruby版本2.2.4p230 RubyGem版本2.7.2 安装了Ruby-devel和lib64ffi-devel。 使用64位OpenMandriva 3.0,urpmi和rpmdrake。 目标:安装指南针,但首先需要gemffi。 在过去的两天里,我一直在努力搜索互联网,我很难过……我不可能安装早期版本的ruby,因为它依赖于较旧的ncurses。 我觉得替换ncurses会打开一jar令人讨厌的蠕虫。 但是……我也完全接受罗盘替代方案,其中config.rb项目文件可以以某种方式移植/复制,因此罗盘和其他sass编译器都可以运行。 (这是为了工作,我们不会很快改变sass建设者)。 /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c完全存在,该目录中有一个ffi.c文件,但在附近找不到任何ffi.h文件。 在绝望的时刻,我触摸了该目录中的ffi.h,当我运行gem install时将其删除。 ;)我会尝试取一个别人的libs副本,看看是否有效。 基本上任何方法都可以在不破坏我的其他包的情况下实现这一点。 我不会用ruby做任何其他事情,只需指南针。 这是输出: # sudo gem install ffi Building native extensions. This could take a while… ERROR: Error installing ffi: ERROR: Failed to build gem native extension. current directory: /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c /usr/bin/ruby -r ./siteconf20171110-17988-1lodsok.rb extconf.rb checking for ffi.h… *** extconf.rb failed *** […]

是否可以使用Fiddle传递结构或将结构返回到本机代码?

我想使用Fiddle访问从Rust代码编译的本机库。 结构的C表示非常简单,它只是一个指针和一个长度: typedef struct { char *data; size_t len; } my_thing_t; // Example function that somehow accepts a struct void accepts_a_struct(my_thing_t thing); // Example function that somehow returns a struct my_thing_t returns_a_struct(void); 但是,我可以找到的所有示例都接受或返回指向结构的指针,而不是结构本身。 如果可能的话,我想避免双重间接。 我借用了Fiddle::Importer文档中的一个例子。 但是,我没有看到如何使用结构而不是指向结构的指针正确调用extern方法: require ‘fiddle’ require ‘fiddle/import’ module LibSum extend Fiddle::Importer dlload ‘./libsum.so’ extern ‘double sum(double*, int)’ extern ‘double split(double)’ end 注意 […]

如何在Heroku上安装ffi

今天开始我们的Heroku部署。 Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /tmp/build_6e4275c6-8442-4a39-9175-f20505baf383/vendor/ruby-2.0.0/bin/ruby extconf.rb checking for ffi.h… no checking for ffi.h in /usr/local/include,/usr/include/ffi… no checking for rb_thread_blocking_region()… yes checking for rb_thread_call_with_gvl()… yes checking for rb_thread_call_without_gvl()… yes checking for ffi_prep_cif_var()… no creating extconf.h creating Makefile make “DESTDIR=” Configuring libffi make -C “/tmp/build_6e4275c6-8442-4a39-9175-f20505baf383/vendor/bundle/ruby/2.0.0/gems/ffi-1.9.3/ext/ffi_c/libffi-x86_64-linux” make[1]: Entering directory `/tmp/build_6e4275c6-8442-4a39-9175-f20505baf383/vendor/bundle/ruby/2.0.0/gems/ffi-1.9.3/ext/ffi_c/libffi-x86_64-linux’ 最近添加的gem包括ffi: gem ‘sass’, […]

安装ffi(1.1.2)时发生错误,Bundler无法继续

在Rails 3.0项目中运行OSX Mountain Lion。 当尝试使用Rails项目中的bundler更新我的gem时,我得到以下错误: An error occured while installing ffi (1.1.2), and Bundler cannot continue. Make sure that `gem install ffi -v ‘1.1.2’` succeeds before bundling. ERROR: Error installing ffi: ERROR: Failed to build gem native extension. /Users/victorstan/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb checking for ffi.h… *** extconf.rb failed *** Could not create Makefile due to some reason, […]

在ffi上捆绑更新失败

我正在尝试在我的rails应用程序上进行bundle update ,但是我收到以下错误: Installing ffi (1.0.11) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks! /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions’: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb checking for ffi.h… *** extconf.rb failed […]

超时,系统超时和终结器不适用于基于FFI的function

我已经通过FFI为共享库函数(第三方函数)编写了一个包装器。 此共享库尝试与服务器建立连接。 在连接建立期间,当服务器无法访问时,第三方function等待3分钟。 为了避免在调用rails时我曾尝试使用以下超时但不幸的是它没有用。 本机超时 系统超时 终结者 注意:当我使用终结者时,由它创建的附加进程正在变为失效进程。 我使用的是ruby企业版1.8

如何处理ruby ffi gem中的ruby数组?

我想使用ruby ffi gem来调用ac函数,它有一个数组作为输入变量,输出是一个数组。 也就是说,c函数看起来像: double *my_function(double array[], int size) 我创建了ruby绑定: module MyModule extend FFI::Library ffi_lib ‘c’ ffi_lib ‘my_c_lib’ attach_function :my_function, [:pointer, int], :pointer 我想用ruby代码打电话,如: result_array = MyModule.my_function([4, 6, 4], 3) 我该怎么做?

如何在以结构为参数的Ruby FFI方法中包装函数?

我试图使用ruby-ffi从共享对象调用函数。 我将以下内容编译成共享对象: #include typedef struct _WHAT { int d; void * something; } WHAT; int doit(WHAT w) { printf(“%d\n”, wd); return wd; } 问题是,如何在Ruby中使用attach_function声明函数? 如何在Ruby中的参数列表中定义struct参数(WHAT w)? 它不是:指针,并且似乎不适合ruby-ffi文档中描述的任何其他可用类型,那么它会是什么?

库未加载:/opt/local/lib/libffi.5.dylib但是我正在使用自制程序

我正试图在Mac OS X Lion(XCode 4.3 + OSX GCC Installer + Homebrew)上守卫 错误信息: Library not loaded: /opt/local/lib/libffi.5.dylib 我没有/opt/local目录,因为我没有使用MacPorts而是使用Homebrew 我尝试了brew install libffi ,这是成功的,但gem仍然不起作用。 我也试过卸载并重新安装gem而没有成功。 在安装了apple-gcc42 OSX 10.9(Mavericks)上也会出现问题。 我也试过告诉gem有关libffi的存在,如下所示: gem install ffi:1.0.7 — –with-ldflags=’-L/usr/local/opt/libffi/lib’

无法安装指南针

上周我因为bash“易受攻击的问题”而在cygwin上做了更新。 之后我再也无法编译sass了。 我尝试重新安装ruby,在一些安装失败后重新安装cygwin我安装了它并更新了 “gem update –system” 它运行,但当我尝试安装指南针时,我得到以下消息: > /usr/bin/ruby.exe -r ./siteconf20141006-7856-1td7wzb.rb extconf.rb > checking for ffi.h… *** extconf.rb failed *** Could not create > Makefile due to some reason, probably lack of necessary libraries > and/or headers. Check the mkmf.log file for more details. You may > need configuration options. > > Provided configuration options: […]