termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.22k stars 3.04k forks source link

/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory #7153

Closed liukangcc closed 3 years ago

liukangcc commented 3 years ago

Not found crypt.h: No such file or directory

~/python $ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/python $ nuitka3 --module hello.py --output-dir=out
Nuitka-Options:INFO: Used command line options: --module hello.py --output-dir=out
Nuitka:INFO: Starting Python compilation with Nuitka '0.6.16.2' on Python '3.9' commercial None.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C level backend compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Backend C:   0%|                                                                           | 0/11In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from __constants.c:2:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
Backend C:  18%|█████████████▋                                                             | 2/11In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from __helpers.c:4:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
In file included from __loader.c:4:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from module.hello.c:19:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
Backend C:  36%|███████████████████████████▎                                               | 4/11scons: *** [__constants.os] Error 1
scons: *** [__helpers.os] Error 1
scons: *** [__loader.os] Error 1
scons: *** [module.hello.os] Error 1
In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from static_src/CompiledCellType.c:19:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
scons: *** [static_src/CompiledCellType.os] Error 1
In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from static_src/CompiledFunctionType.c:19:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
scons: *** [static_src/CompiledFunctionType.os] Error 1
In file included from /data/data/com.termux/files/usr/lib/python3.9/site-packages/nuitka/build/include/nuitka/prelude.h:47,
                 from static_src/CompiledGeneratorType.c:28:
/data/data/com.termux/files/usr/include/python3.9/Python.h:44:10: fatal error: crypt.h: No such file or directory
   44 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
Backend C:  73%|██████████████████████████████████████████████████████▌                    | 8/11scons: *** [static_src/CompiledGeneratorType.os] Error 1
~/python $ pkg install python-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python

E: Package 'python-dev' has no installation candidate
~/python $ pkg install libcrypt-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package libcrypt-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libcrypt

E: Package 'libcrypt-dev' has no installation candidate
~/python $
ghost commented 3 years ago

pkg install libcrypt

Also there no dev packages. Termux no longer does splitting. So libcrypt-dev == libcrypt, same with other packages.

liukangcc commented 3 years ago

pkg install libcrypt

Also there no dev packages. Termux no longer does splitting. So libcrypt-dev == libcrypt, same with other packages.

My question is : error: crypt.h: No such file or directory

suhan-paradkar commented 3 years ago

My question is : error: crypt.h: No such file or directory

Yea.. that can be solved by pkg install libcrypt

liukangcc commented 3 years ago

My question is : error: crypt.h: No such file or directory

Yea.. that can be solved by pkg install libcrypt

I have already installed libcrypt


$ pkg install libcrypt
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libcrypt is already the newest version (0.2-3).
The following package was automatically installed and is no longer required:
  zstd
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded

$ apt list
libcroco-static/stable,stable 0.6.13-5 aarch64
libcroco/stable,stable 0.6.13-5 aarch64
libcrypt/stable,stable,now 0.2-3 aarch64 [installed]
libcue/stable,stable 2.2.1-1 aarch64
libcunit-static/stable,stable 2.1.3 aarch64
libcunit/stable,stable 2.1.3 aarch64
libcurl-static/stable,stable 7.77.0-3 aarch64
libcurl/stable,stable,now 7.77.0-3 aarch64 [installed]
libczmq-static/stable,stable 4.2.1 aarch64
libczmq/stable,stable 4.2.1 aarch64
libdav1d/stable,stable 0.9.0 aarch64
suhan-paradkar commented 3 years ago

You may need to manually specify CPPFLAGS.. Pointing to $PREFIX/include

ghost commented 3 years ago

Yes, crypt.h is in $PREFIX/include.

You may also try termux-chroot, if your build tool tries to use locations like /usr/include which do not exist in Termux because it is not FHS-compliant.

liukangcc commented 3 years ago

Yes, crypt.h is in $PREFIX/include.

You may also try termux-chroot, if your build tool tries to use locations like /usr/include which do not exist in Termux because it is not FHS-compliant.

Amazing, It's work! Thanks for your help!

liukangcc commented 3 years ago

Yes, crypt.h is in $PREFIX/include. You may also try termux-chroot, if your build tool tries to use locations like /usr/include which do not exist in Termux because it is not FHS-compliant.

Amazing, It's work! Thanks for your help!

Other problems arose:

image

suhan-paradkar commented 3 years ago

Maybe disabling nls may help

ghost commented 3 years ago

@suhan-paradkar There issues with threading, not with NLS. Termux (Android) has limited support for pthreads. Many stuff is missing.

gcc isn't supported by Termux officially, this could also lead to problems. clang should be used instead. The right use of gcc is only for GNU extensions of C language, which are not parts of the standard C. Though nowadays only rare software relies on GNU extensions.

liukangcc commented 3 years ago

There issues with threading, not with NLS. Termux (Android) has limited support for pthreads. Many stuff is missing.

gcc isn't supported by Termux officially, this could also lead to problems. clang should be used instead. The right use of gcc is only for GNU extensions of C language, which are not parts of the standard C. Though nowadays only rare software relies on GNU extensions.

Does Termux's Python support packaging as a dynamic library? Then use my C code to call the Python generated .so file?

I have tested some Python packaging tools and found that the resulting.so file cannot be called. such as: Nuitka.

I asked the author of Nuitka, and this is his response: https://github.com/Nuitka/Nuitka/issues/1163.

What's different about the Python environment on the Termux?

ghost commented 3 years ago

Yes, our Python supports dynamic libraries.

Your issue is most likely https://github.com/android-ndk/ndk/issues/201. Binary doesn't expose symbols to loaded shared libraries. You should link your .so file with libpython to obtain symbols, otherwise it would not work. Android dynamic linker is not same as on normal Linux distributions - that's one of major differences you should know when using Termux.

If you need a traditional behavior, then use proot'ed or chroot'ed variants of Linux distributions inside Termux either through proot-distro or third-party installers.