标签: libffi

使用 cffi-libffi 按值传递结构?

我的印象是 CFFI 不能按值传递结构,但 CFFI 文档说:

要将结构按值传递或返回给函数,请加载 cffi-libffi 系统并将结构指定为(:struct structure-name)。要传递或返回指针,您可以使用:pointer(:pointer (:struct structure-name))

我正在重新包装 cl-opencv 函数get-size,它是这个 opencv 函数的包装器:

CvSize cvGetSize(const CvArr* arr)
Run Code Online (Sandbox Code Playgroud)

并且由于我认为 CFFI 在 cl-opencv 的作者编写库时无法使用 cffi-libffi 系统按值传递结构体,因此他不得不使用以下所有代码来包装cvGetSize

 (defmacro make-structure-serializers (struct slot1 slot2)
  "Create a serialization and deserialization function for the
structure STRUCT with integer slots SLOT1 and SLOT2. These functions
will pack and unpack the structure into an INT64."
  (let ((pack-fn (intern (concatenate 'string (string struct) 
                       (string '->int64))))
    (slot1-fn (intern …
Run Code Online (Sandbox Code Playgroud)

c opencv common-lisp libffi cffi

5
推荐指数
1
解决办法
1977
查看次数

如何在Mac OS X上安装libffi-dev

我正在尝试在unix上实现micropython,这需要libffi-dev.我安装这种方式brew install libffi-dev.但似乎没有找到libffi-dev.

有没有办法libffi-dev在Mac OS 上安装.谢谢.

macos homebrew libffi micropython

5
推荐指数
1
解决办法
7961
查看次数

OSX stat() 和 libffi

我正在尝试使用 libffi 在 macos (10.11) 上访问 stat()。这是用于 SWI-Prolog 的新的基于 FFI 的外部接口的一部分。该接口解析<sys/stat.h>头以获取函数原型和struct stat类型。但是,我得到了虚假的值。如果我编译下面的代码并mystat从生成的.dylib.

#include <sys/stat.h>

int
mystat(const char *name, struct stat *buf)
{ return stat(name, buf);
}
Run Code Online (Sandbox Code Playgroud)

我怀疑我statdlsym(). /usr/lib/libc.dylib和都试过了/usr/lib/libSystem.B.dylib。这给出了相同的结果。如果我nm在上面的 dylib 上运行,我会得到 U _stat$INODE64. dlsym不适用于stat$INODE64. 查看 libc.dylib 我们得到

534_> nm /usr/lib/libc.dylib | grep stat
0000000000001ac5 T R8289209$_pthread_attr_setdetachstate
0000000000001af7 T R8289209$_stat
                 U _pthread_attr_setdetachstate
                 U _stat
Run Code Online (Sandbox Code Playgroud)

两者有什么关系?任何人都知道可能会发生什么?

macos dylib libffi

5
推荐指数
1
解决办法
311
查看次数

如何在 Windows 上安装 libffi-dev 和 libssl-dev

我正在尝试使用 运行一段代码paramiko,但收到错误消息ImportError: No module named cryptography.hazmat.backends。双方paramikocryptography已安装。

就我在各种论坛上的阅读而言,我需要安装libffi-dev(也许还需要安装libssl-dev)。但是,我能找到的所有解决方案都适用于 Ubuntu 或 Mac OS。如何在 Windows 10 上安装它们?

python paramiko libffi python-2.7 anaconda

5
推荐指数
1
解决办法
7363
查看次数

为 Python 3.7 安装 libffi-dev 时出现问题

当尝试在 Ubuntu 系统上以桌面模式安装 pgadmin4 时,我收到了 _ctypes 的 ModuleNotFoundError。

我做了一些研究,发现 _ctypes 需要安装 libffi-dev 包。然而,似乎 libffi-dev 和 _ctypes 是为 Python 2.7 安装的,当我运行 import ctypes 时,它似乎可以工作:

$ python2
Python 2.7.15+ (default, Nov 27 2018, 23:36:35) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> 

Run Code Online (Sandbox Code Playgroud)

当我尝试对 Python 3.7 执行相同操作时,它不起作用:

$ python
Python 3.7.3 (default, Jun 21 2019, 12:46:58) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most …
Run Code Online (Sandbox Code Playgroud)

ubuntu ctypes libffi python-3.x

5
推荐指数
1
解决办法
1万
查看次数

自定义LIBFFI Heroku buildpack的问题

我正在尝试将我的应用程序部署到Heroku.它正在使用pyOpenSSL,这需要cryptography,这需要libffi.我在libffi这里找到了一个自定义buildpack :https://github.com/mfenniak/heroku-buildpack-python-libffi.然而,cryptography似乎无法找到,libffi即使它是LD_LIBRARY_PATH:

$ heroku run bash

heroku> echo $LD_LIBRARY_PATH
/app/.heroku/vendor/lib:/app/vendor/libffi-3.0/lib

heroku> ls /app/vendor/libffi-3.0/lib
libffi-3.0.13  libffi.a  libffi.la  libffi.so  libffi.so.6  libffi.so.6.0.1  pkgconfig
Run Code Online (Sandbox Code Playgroud)

但是,我不确定LD_LIBRARY_PATH在安装过程中是否可用,但它是buildpack的编译步骤的一部分:https://github.com/mfenniak/heroku-buildpack-python-libffi/commit/6ce48d4fd6c55fc3dc462cf6300c17854732b6e2

一般来说,这个buildpack可以工作,我之前使用它bcrypt(https://pypi.python.org/pypi/bcrypt).

这是heroku部署过程失败:

$ git push staging master
Fetching repository, done.
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.71 KiB …
Run Code Online (Sandbox Code Playgroud)

python openssl cryptography heroku libffi

4
推荐指数
1
解决办法
2227
查看次数

libffi.so.8:无法打开共享对象文件

我将 Rails 升级到 7.0.1。当我这样做时rails g controller Pages home,它给出了错误:

>>rails g controller Pages home
/home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require': libffi.so.8: cannot open shared object file: No such file or directory - /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.5/lib/ffi_c.so (LoadError)
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ffi-
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootstrap-5.1.3/lib/bootstrap/engine.rb:4:in `<main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/sassc-rails-2.1.2/lib/sassc/rails.rb:5:in `<main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bundler-2.3.5/lib/bundler.rb:176:in `require'
        from /home/shadman/instagram/config/application.rb:7:in `<main>'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/shadman/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.10.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails libffi ruby-on-rails-7

4
推荐指数
1
解决办法
4629
查看次数