Installing cffi fails with c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

1,698 views
Skip to first unread message

ssci...@gmail.com

unread,
Nov 17, 2017, 5:31:51 AM11/17/17
to python-cffi
I've been trying to install cffi for a while and I'm not having any luck.

Here's a list of packages I have installed so far:

$ pip3 freeze

asn1crypto==0.23.0

attrs==17.3.0

autobahn==17.10.1

Automat==0.6.0

constantly==15.1.0

ez-setup==0.9

hyperlink==17.3.1

idna==2.6

incremental==17.5.0

pycparser==2.18

pyserial==3.4

six==1.11.0

txaio==2.8.2

virtualenv==15.1.0

zope.interface==4.4.3


-------------------------------------------------
When I run `opkg list-installed`, I get:

root@automate:/etc# opkg list-installed

ar - 2.24-3

avrdude - 6.1-1

base-files - 157.2-r49389

binutils - 2.24-3

blkid - 2.25.2-4

block-mount - 2016-01-10-96415afecef35766332067f4205ef3b2c7561d21

busybox - 1.23.2-1

bzip2 - 1.0.6-2

cpu-mcu-bridge - 1.6.0-1

dnsmasq - 2.73-1

dropbear - 2015.67-1

e2fsprogs - 1.42.12-1

fdisk - 2.25.2-4

firewall - 2015-07-27

fstools - 2016-01-10-96415afecef35766332067f4205ef3b2c7561d21

gcc - 4.8.3-1

glib2 - 2.43.4-1

gnupg - 1.4.19-1

hidapi - 0.8.0-rc1-1

hostapd-common - 2015-03-25-1

ip6tables - 1.4.21-1

iptables - 1.4.21-1

iw - 4.3-1

iwinfo - 2015-06-01-ade8b1b299cbd5748db1acf80dd3e9f567938371

jshn - 2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb

jsonfilter - 2014-06-19-cdc760c58077f44fc40adbbe41e1556a67c1b9a9

kernel - 3.18.45-1-ffac271cea71f1a1f46f2d50f85d434b

kmod-ath - 3.18.45+2016-01-10-1

kmod-ath9k - 3.18.45+2016-01-10-1

kmod-ath9k-common - 3.18.45+2016-01-10-1

kmod-atm - 3.18.45-1

kmod-cfg80211 - 3.18.45+2016-01-10-1

kmod-crypto-aes - 3.18.45-1

kmod-crypto-arc4 - 3.18.45-1

kmod-crypto-core - 3.18.45-1

kmod-crypto-hash - 3.18.45-1

kmod-fs-ext4 - 3.18.45-1

kmod-fs-hfs - 3.18.45-1

kmod-fs-hfsplus - 3.18.45-1

kmod-fs-ntfs - 3.18.45-1

kmod-fs-reiserfs - 3.18.45-1

kmod-fs-vfat - 3.18.45-1

kmod-fuse - 3.18.45-1

kmod-hid - 3.18.45-1

kmod-input-core - 3.18.45-1

kmod-input-evdev - 3.18.45-1

kmod-input-gpio-keys-polled - 3.18.45-1

kmod-input-polldev - 3.18.45-1

kmod-ip6tables - 3.18.45-1

kmod-ipt-conntrack - 3.18.45-1

kmod-ipt-core - 3.18.45-1

kmod-ipt-nat - 3.18.45-1

kmod-ipv6 - 3.18.45-1

kmod-leds-gpio - 3.18.45-1

kmod-ledtrig-default-on - 3.18.45-1

kmod-ledtrig-netdev - 3.18.45-1

kmod-ledtrig-timer - 3.18.45-1

kmod-lib-crc-ccitt - 3.18.45-1

kmod-lib-crc16 - 3.18.45-1

kmod-loop - 3.18.45-1

kmod-mac80211 - 3.18.45+2016-01-10-1

kmod-nf-conntrack - 3.18.45-1

kmod-nf-conntrack6 - 3.18.45-1

kmod-nf-ipt - 3.18.45-1

kmod-nf-ipt6 - 3.18.45-1

kmod-nf-nat - 3.18.45-1

kmod-nf-nathelper - 3.18.45-1

kmod-nls-base - 3.18.45-1

kmod-nls-cp437 - 3.18.45-1

kmod-nls-iso8859-1 - 3.18.45-1

kmod-nls-utf8 - 3.18.45-1

kmod-ppp - 3.18.45-1

kmod-pppoe - 3.18.45-1

kmod-pppox - 3.18.45-1

kmod-scsi-core - 3.18.45-1

kmod-slhc - 3.18.45-1

kmod-usb-atm - 3.18.45-1

kmod-usb-core - 3.18.45-1

kmod-usb-ohci - 3.18.45-1

kmod-usb-storage - 3.18.45-1

kmod-usb2 - 3.18.45-1

ldd - 0.9.33.2-1

libacl - 20140812-1

libattr - 20150220-1

libbfd - 2.24-3

libblkid - 2.25.2-4

libblobmsg-json - 2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb

libbz2 - 1.0.6-2

libc - 0.9.33.2-1

libdaemon - 0.14-5

libdb47 - 4.7.25.4.NC-4.1

libelf1 - 0.161-1

libexpat - 2.1.0-3

libext2fs - 1.42.12-1

libffi - 3.2.1-3

libftdi - 0.20-3

libftdi1 - 1.2-3

libgcc - 4.8-linaro-1

libgdbm - 1.11-1

libgpg-error - 1.12-1

libiconv - 7

libip4tc - 1.4.21-1

libip6tc - 1.4.21-1

libiwinfo - 2015-06-01-ade8b1b299cbd5748db1acf80dd3e9f567938371

libiwinfo-lua - 2015-06-01-ade8b1b299cbd5748db1acf80dd3e9f567938371

libjson-c - 0.12-1

libjson-script - 2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb

liblua - 5.1.5-1

liblzma - 5.2.1-2

libncurses - 5.9-2

libnl-tiny - 0.1-4

libopcodes - 2.24-3

libopenssl - 1.0.2j-1

libpcre - 8.39-1

libpolarssl - 1.3.14-1

libpopt - 1.16-1

libpthread - 0.9.33.2-1

libreadline - 6.3-1

librt - 0.9.33.2-1

libsmartcols - 2.25.2-4

libsqlite3 - 3081101-1

libstdcpp - 4.8-linaro-1

libubox - 2015-11-08-10429bccd0dc5d204635e110a7a8fae7b80d16cb

libubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e

libubus-lua - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e

libuci - 2015-08-27.1-1

libuci-lua - 2015-08-27.1-1

libusb-1.0 - 1.0.19-1

libusb-compat - 0.1.4-1

libustream-polarssl - 2015-07-09-c2d73c22618e8ee444e8d346695eca908ecb72d3

libuuid - 2.25.2-4

libxml2 - 2.9.2-3

libxtables - 1.4.21-1

logd - 2015-11-22-c086167a0154745c677f8730a336ea9cf7d71031

lua - 5.1.5-1

luci - git-16.344.58491-d4bec26-1

luci-app-arduino-webpanel - 1.5.7-1

luci-app-firewall - git-16.344.58491-d4bec26-1

luci-base - git-16.344.58491-d4bec26-1

luci-lib-ip - git-16.344.58491-d4bec26-1

luci-lib-json - git-16.344.58491-d4bec26-1

luci-lib-nixio - git-16.344.58491-d4bec26-1

luci-mod-admin-full - git-16.344.58491-d4bec26-1

luci-proto-ipv6 - git-16.344.58491-d4bec26-1

luci-proto-ppp - git-16.344.58491-d4bec26-1

luci-ssl - git-16.344.58491-d4bec26-1

luci-theme-bootstrap - git-16.344.58491-d4bec26-1

mkdosfs - 3.0.28-1

mtd - 21

netifd - 2015-12-16-245527193e90906451be35c2b8e972b8712ea6ab

objdump - 2.24-3

odhcp6c - 2016-02-08-dc186d6d2b0dd4ad23ca5fc69c00e81f796ff6d9

odhcpd - 2016-10-09-801cfeea100ca7b211c9841f0fcb757b17f47860

openssh-sftp-server - 7.1p2-1

openssl-util - 1.0.2j-1

opkg - 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-9

ppp - 2.4.7-6

ppp-mod-pppoe - 2.4.7-6

procd - 2015-10-29.1-d5fddd91b966424bb63e943e789704d52382cc18

px5g - 3

python3 - 3.5.0-3

python3-asyncio - 3.5.0-3

python3-base - 3.5.0-3

python3-codecs - 3.5.0-3

python3-ctypes - 3.5.0-3

python3-dbm - 3.5.0-3

python3-decimal - 3.5.0-3

python3-dev - 3.5.0-3

python3-distutils - 3.5.0-3

python3-email - 3.5.0-3

python3-gdbm - 3.5.0-3

python3-lib2to3 - 3.5.0-3

python3-light - 3.5.0-3

python3-logging - 3.5.0-3

python3-lzma - 3.5.0-3

python3-multiprocessing - 3.5.0-3

python3-ncurses - 3.5.0-3

python3-openssl - 3.5.0-3

python3-pip - 7.1.2-1

python3-pydoc - 3.5.0-3

python3-setuptools - 19.4-1

python3-sqlite3 - 3.5.0-3

python3-unittest - 3.5.0-3

python3-xml - 3.5.0-3

rng-tools - 5-1

rpcd - 2016-06-30-23417e94d25570e6d62542bac46edd51e8e0243a

rsync - 3.1.1-2

swconfig - 10

tar - 1.28-2

terminfo - 5.9-2

triggerhappy - 0.3.4-2

uSDaemon - 1.0.0-1

uboot-envtools - 2014.10-2

ubox - 2015-11-22-c086167a0154745c677f8730a336ea9cf7d71031

ubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e

ubusd - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e

uci - 2015-08-27.1-1

uhttpd - 2015-11-08-fe01ef3f52adae9da38ef47926cd50974af5d6b7

uhttpd-mod-lua - 2015-11-08-fe01ef3f52adae9da38ef47926cd50974af5d6b7

uhttpd-mod-ubus - 2015-11-08-fe01ef3f52adae9da38ef47926cd50974af5d6b7

unzip - 6.0-3

usign - 2015-05-08-cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131

wget - 1.17.1-1

wpad-mini - 2015-03-25-1

yun-conf - 1.2.0-2

yun-scripts - 1.3-1

zlib - 1.2.8-1



----------------------------------------------------------
Finally, this happens when I try to install cffi:

root@automate:/etc# pip3 install cffi

Collecting cffi

  Using cached cffi-1.11.2.tar.gz

Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/lib/python3.5/site-packages (from cffi)

Installing collected packages: cffi

  Running setup.py install for cffi

    Complete output from command /usr/bin/python3.5 -c "import setuptools, tokenize;__file__='/tmp/pip-build-0y7c5tc2/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-onezqimp-record/install-record.txt --single-version-externally-managed --compile:

    running install

    running build

    running build_py

    creating build

    creating build/lib.linux-mips-3.5

    creating build/lib.linux-mips-3.5/cffi

    copying cffi/recompiler.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/verifier.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/cffi_opcode.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/setuptools_ext.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/__init__.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/lock.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/api.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/vengine_gen.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/ffiplatform.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/cparser.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/backend_ctypes.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/error.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/commontypes.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/model.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/vengine_cpy.py -> build/lib.linux-mips-3.5/cffi

    copying cffi/_cffi_include.h -> build/lib.linux-mips-3.5/cffi

    copying cffi/parse_c_type.h -> build/lib.linux-mips-3.5/cffi

    copying cffi/_embedding.h -> build/lib.linux-mips-3.5/cffi

    copying cffi/_cffi_errors.h -> build/lib.linux-mips-3.5/cffi

    warning: build_py: byte-compiling is disabled, skipping.

    

    running build_ext

    building '_cffi_backend' extension

    creating build/temp.linux-mips-3.5

    creating build/temp.linux-mips-3.5/c

    mips-openwrt-linux-uclibc-gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mno-mips16 -mno-interlink-mips16 -Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mno-mips16 -mno-interlink-mips16 -DNDEBUG -fno-inline -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.5 -c c/_cffi_backend.c -o build/temp.linux-mips-3.5/c/_cffi_backend.o

    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

     #include <ffi.h>

                     ^

    compilation terminated.

    error: command 'mips-openwrt-linux-uclibc-gcc' failed with exit status 1

    

    ----------------------------------------

Command "/usr/bin/python3.5 -c "import setuptools, tokenize;__file__='/tmp/pip-build-0y7c5tc2/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-onezqimp-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-0y7c5tc2/cffi



There is VERY little information online about this error - I've been trying for many hours without any luck. gcc is installed, libffi is installed.

Neil Muller

unread,
Nov 17, 2017, 5:57:22 AM11/17/17
to pytho...@googlegroups.com
On 17 November 2017 at 12:31, <ssci...@gmail.com> wrote:
> I've been trying to install cffi for a while and I'm not having any luck.
>
> Here's a list of packages I have installed so far:
>
> -------------------------------------------------
> When I run `opkg list-installed`, I get:
>

You appear to be missing the header and development libraries for libffi.

Packages build for opkg typically strip these out of the package,
because they take up space and have little use on the sort of devices
opkg is targetting. You'll probably have to recompile the package
yourself to include the required bits.

Why are you looking to install python-cffi directly, though? AFAIK,
openwrt provides a python-cffi packages already.

--
Neil Muller
drnlm...@gmail.com

I've got a gmail account. Why haven't I become cool?

ssci...@gmail.com

unread,
Nov 18, 2017, 1:29:00 PM11/18/17
to python-cffi
The ffi.h error is happening with both methods I tried:
I need to install cffi because I need to get cryptography to work, and `pip install cryptography` keeps failing at cffi.

If this requires 'recompiling the package yourself', I don't know how to do that. Any help would be massively appreciated.

Armin Rigo

unread,
Nov 19, 2017, 4:14:52 AM11/19/17
to pytho...@googlegroups.com
Hi,

On 18 November 2017 at 19:29, <ssci...@gmail.com> wrote:
> I need to install cffi because I need to get cryptography to work, and `pip
> install cryptography` keeps failing at cffi.

You need to install the development version of "libffi", which is a
non-Python dependency of cffi.

Try something like "opkg install libffi-dev" or similar.


Armin

ssci...@gmail.com

unread,
Nov 19, 2017, 12:44:52 PM11/19/17
to python-cffi
Hi,

Unfortunately, `opkg update; opkg list | grep libffi` only produces libffi 3.0.13-1 (already installed), not libffi-dev.

If this is the next course of action, how can I manually install / configure / compile libffi-dev?

Thank you.

Armin Rigo

unread,
Nov 19, 2017, 4:31:56 PM11/19/17
to pytho...@googlegroups.com
Hi,

On 19 November 2017 at 18:44, <ssci...@gmail.com> wrote:
> Unfortunately, `opkg update; opkg list | grep libffi` only produces libffi
> 3.0.13-1 (already installed), not libffi-dev.
>
> If this is the next course of action, how can I manually install / configure
> / compile libffi-dev?

You should either ask on the mailing list for your Linux distribution,
or google around to find the source code of libffi and try to compile
it manually.


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages