# Error building Python3 on openSUSE

**URL:** <https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764>\
**Category:** For Developers\
**Created:** [September 22, 2018, 9:35am UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764 "2018-09-22T09:35:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jan/32/135636_2.png) [@jan](https://forum.openwrt.org/u/jan)\
**Post date:** [September 22, 2018, 9:35am UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/1 "2018-09-22T09:35:25Z")

</div>

Building Python3 OpenWRT 18.06.1 on openSUSE LEAP 15.0:

> gcc -shared -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib64 -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib64 -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib64 -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -O2 -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/include -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/include -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/include -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/include -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/include -I/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/include build/temp.linux-x86\_64-3.6/local/jan/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/\_ctypes.o build/temp.linux-x86\_64-3.6/local/jan/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/callbacks.o build/temp.linux-x86\_64-3.6/local/jan/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/callproc.o build/temp.linux-x86\_64-3.6/local/jan/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/stgdict.o build/temp.linux-x86\_64-3.6/local/jan/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/cfield.o -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/local/jan/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -lffi -ldl -o build/lib.linux-x86\_64-3.6/\_ctypes.cpython-36.so  
> \*\*\* WARNING: renaming "\_ctypes" since importing it failed: libffi.so.6: cannot open shared object file: No such file or directory
> 
> Python build finished successfully!  
> The necessary bits to build these optional modules were not found:  
> \_tkinter  
> To find the necessary bits, look in setup.py in detect\_modules() for the module's name.
> 
> The following modules found by detect\_modules() in setup.py, have been  
> built by the Makefile instead, as configured by the Setup files:  
> atexit pwd time  
> zlib
> 
> Failed to build these modules:  
> \_lzma \_ssl
> 
> Following modules built successfully but were removed because they could not be imported:  
> \_ctypes

Later on the lack of the \_ctypes module is fatal. My guess is the import test uses the wrong path, and looks in the host system where there is no libffi.so.6, the host has libffi.so.7. The same config and OpenWRT version builds on Ubuntu (I guess it's Ubuntu 18.04):

> gcc -pthread -shared -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -lssl -lresolv -lcrypto -lpthread -lcrypto -lresolv -lpthread -Wl,--no-as-needed -lrt -O2 -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/include -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/include -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/include -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/include -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/include -I/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/target-arm\_cortex-a8+vfpv3\_musl\_eabi/host/include build/temp.linux-x86\_64-3.6/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/\_ctypes.o build/temp.linux-x86\_64-3.6/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/callbacks.o build/temp.linux-x86\_64-3.6/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/callproc.o build/temp.linux-x86\_64-3.6/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/stgdict.o build/temp.linux-x86\_64-3.6/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/build\_dir/hostpkg/Python-3.6.5/Modules/\_ctypes/cfield.o -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/host/lib -L/home/oen/work/gtu/mcg/openwrt-h1164-mockup-25/staging\_dir/hostpkg/lib -lffi -ldl -o build/lib.linux-x86\_64-3.6/\_ctypes.cpython-36.so  
> \*\*\* WARNING: renaming "\_crypt" since importing it failed: build/lib.linux-x86\_64-3.6/\_crypt.cpython-36.so: undefined symbol: crypt  
> \*\*\* WARNING: renaming "nis" since importing it failed: build/lib.linux-x86\_64-3.6/nis.cpython-36.so: undefined symbol: yp\_master
> 
> Python build finished successfully!  
> The necessary bits to build these optional modules were not found:  
> \_curses \_curses\_panel \_dbm  
> \_gdbm \_sqlite3 \_tkinter  
> readline  
> To find the necessary bits, look in setup.py in detect\_modules() for the module's name.
> 
> The following modules found by detect\_modules() in setup.py, have been  
> built by the Makefile instead, as configured by the Setup files:  
> atexit pwd time  
> zlib
> 
> Failed to build these modules:  
> \_lzma \_ssl
> 
> Following modules built successfully but were removed because they could not be imported:  
> \_crypt nis

Maybee Ubuntu uses the same version of libffi, I don't currently have access to that machine so I cannot check.

By symlinking /usr/lib64/libffi.so.6 to /usr/lib64/libffi.so.7 the build gets passed this, indicating that my assumption that the \_ctypes module is linked against staging, but the import test is against the host is correct. But making such a symlink is definitely the wrong solution.

Now I get the following error (now I have also changed packages from 18.06 to master):

> Package python3-light is missing dependencies for the following libraries:  
> libuuid.so.1

But that's another story I suppose.

If there are any experts on the python build I appreciate some help with this. I guess this bug will come and bite people later on when Ubuntu upgrades libffi.

---

<div class="post-metadata">

**Author:** ![robimarko](https://forum.openwrt.org/user_avatar/forum.openwrt.org/robimarko/32/617_2.png) [@robimarko](https://forum.openwrt.org/u/robimarko)\
**Post date:** [September 27, 2018, 11:07am UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/2 "2018-09-27T11:07:34Z")

</div>

You are hitting that issue because 18.06 uses Python 3.6 and PYTHON3\_SO\_SUFFIX:=cpython-$(PYTHON3\_VERSION\_MAJOR)$(PYTHON3\_VERSION\_MINOR).so

So since the host system has a newer libffi it does not match the defined one.  
Master should build, but I have no idea how to build 18.06 on systems that use new libffi.

---

<div class="post-metadata">

**Author:** ![jan](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jan/32/135636_2.png) [@jan](https://forum.openwrt.org/u/jan)\
**Post date:** [September 27, 2018, 4:13pm UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/3 "2018-09-27T16:13:35Z")

</div>

No, packages master fails to build python 3.7.0

---

<div class="post-metadata">

**Author:** ![robimarko](https://forum.openwrt.org/user_avatar/forum.openwrt.org/robimarko/32/617_2.png) [@robimarko](https://forum.openwrt.org/u/robimarko)\
**Post date:** [September 27, 2018, 7:04pm UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/4 "2018-09-27T19:04:23Z")

</div>

Hm, then I hit the same issue on Fedora28 and now on 29.  
Tried googling around,but cant find anything similar with any answers

---

<div class="post-metadata">

**Author:** ![bobafetthotmail](https://forum.openwrt.org/user_avatar/forum.openwrt.org/bobafetthotmail/32/39_2.png) [@bobafetthotmail](https://forum.openwrt.org/u/bobafetthotmail)\
**Post date:** [October 1, 2018, 8:41am UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/5 "2018-10-01T08:41:22Z")

</div>

I'm guessing there is something wrong in the makefiles, as they specify where the system should look for to find libraries during the build. But I don't know enough about python nor the makefiles to find the error myself.

The makefiles to compile python are here in the source [https://github.com/openwrt/packages/tree/master/lang/python](https://github.com/openwrt/packages/tree/master/lang/python) (and in the **/feeds/packages/lang/python** in the local folder you use to compile OpenWrt), in case you want to try to look into this yourself.

---

<div class="post-metadata">

**Author:** ![jan](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jan/32/135636_2.png) [@jan](https://forum.openwrt.org/u/jan)\
**Post date:** [October 1, 2018, 5:41pm UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/6 "2018-10-01T17:41:41Z")

</div>

Moved the -rpath linker option in the package makefiles. The change is in [https://github.com/jan-kardell/openwrt-packages/tree/TQ\_fix\_python3](https://github.com/jan-kardell/openwrt-packages/tree/TQ_fix_python3), tried to make a pull request. Master now compiles on LEAP 15.

The build system is a bit complicated, so I am not sure it is the correct fix, but it seems to work.

---

<div class="post-metadata">

**Author:** ![robimarko](https://forum.openwrt.org/user_avatar/forum.openwrt.org/robimarko/32/617_2.png) [@robimarko](https://forum.openwrt.org/u/robimarko)\
**Post date:** [October 1, 2018, 6:15pm UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/7 "2018-10-01T18:15:25Z")

</div>

Will give it a go on Fedora 29.  
Did you open a PR?

---

<div class="post-metadata">

**Author:** ![jan](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jan/32/135636_2.png) [@jan](https://forum.openwrt.org/u/jan)\
**Post date:** [October 1, 2018, 8:08pm UTC](https://forum.openwrt.org/t/error-building-python3-on-opensuse/21764/8 "2018-10-01T20:08:54Z")

</div>

> [@robimarko](#):
>
> Did you open a PR?

Yes, as I wrote, I did a pull request.
