its-pointless / gcc_termux

Gcc for termux with fortran scipy etc... Use apt for newest updates instructions in README.txt
457 stars 74 forks source link

Compilation fails (cdefs.h, stdio.h) #158

Open nitardus opened 1 year ago

nitardus commented 1 year ago

I cannot get gcc to work at all: Even if I try to compile a simple Hello World program, I get the following output:

In file included from /data/data/com.termux/files/usr/include/sys/cdefs.h:429, from /data/data/com.termux/files/usr/include/stdio.h:41, from hello.c:1: /data/data/com.termux/files/usr/include/android/api-level.h:185:50: error: 'stric\ t' undeclared here (not in a function) 185 | int android_get_application_target_sdk_version() INTRODUCED_IN(24); | ^~~~~~~ /data/data/com.termux/files/usr/include/android/api-level.h:185:50: error: 'intro\ duced' undeclared here (not in a function) 185 | int android_get_application_target_sdk_version() INTRODUCED_IN(24);

This is the output of gcc -v:

Reading specs from /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/\ 11.1.0/specs COLLECT_GCC=/data/data/com.termux/files/usr/bin/gcc COLLECT_LTO_WRAPPER=/data/data/com.termux/files/usr/libexec/gcc/aarch64-linux-and\ roid/11.1.0/lto-wrapper Target: aarch64-linux-android Configured with: /home/builder/.termux-build/gcc-11/src/configure --disable-depen\ dency-tracking --prefix=/data/data/com.termux/files/usr --libdir=/data/data/com.t\ ermux/files/usr/lib --sbindir=/data/data/com.termux/files/usr/bin --disable-rpath\ --disable-rpath-hack --host=aarch64-linux-android --enable-languages=c,c++,fortr\ an,jit,objc,ada --with-system-zlib --disable-multilib --target=aarch64-linux-andr\ oid --with-libgfortran --enable-static --with-gmp=/data/data/com.termux/files/usr\ --with-mpfr=/data/data/com.termux/files/usr --with-mpc=/data/data/com.termux/fil\ es/usr --with-isl-include=/data/data/com.termux/files/usr/include --with-isl-lib=\ /data/data/com.termux/files/usr/lib --disable-isl-version-check --disable-libssp \ --with-stage1-ldflags=-specs=/home/builder/.termux-build/gcc-11/tmp/specs --disab\ le-tls --enable-lto --enable-gold=yes --enable-libatomic --program-suffix=-11 --e\ nable-libbacktrace --enable-host-shared --enable-host-libquadmath --enable-libato\ mic-ifuncs=no --enable-default-pie ac_cv_c_bigendian=no --with-libatomic --disabl\ e-libstdcxx --enable-version-specific-runtime-libs --enable-eh-frame-hdr-for-stat\ ic --disable-libmpx -with-gxx-include-dir=/data/data/com.termux/files/usr/include\ /c++/v1 --with-arch=armv8-a --enable-fix-cortex-a53-835769 --enable-fix-cortex-a5\ 3-843419 --enable-libssp --disable-nls --enable-shared --enable-static --libexecd\ ir=/data/data/com.termux/files/usr/libexec Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.1.0 (GCC)

termux-info:

Termux Variables: TERMUX_API_VERSION=0.50.1 TERMUX_APK_RELEASE=F_DROID TERMUX_APP_PACKAGE_MANAGER=apt TERMUX_APP_PID=5792 TERMUX_IS_DEBUGGABLE_BUILD=0 TERMUX_MAIN_PACKAGE_FORMAT=debian TERMUX_VERSION=0.118.0 Packages CPU architecture: aarch64 Subscribed repositories:

sources.list

deb https://grimler.se/termux/termux-main stable main

sources.list.d/pointless.list

deb https://its-pointless.github.io/files/24 termux extras Updatable packages: All packages up to date termux-tools version: 1.38.1 Android version: 13 Kernel build information: Linux localhost 5.10.178-android13-4-gb8b945ed31a7 #1 SMP PREEMPT Tue May 16 17:0\ 1:54 UTC 2023 aarch64 Android Device manufacturer: Google Device model: Pixel 6a LD Variables: LD_LIBRARY_PATH=:/data/data/com.termux/files/usr/lib LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so

Any suggestions what has gone wrong? Thanks!

yyyyyy-0976 commented 1 year ago

Try ndk r16 from this website https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16 Screenshot_20230816-144540_Termux

yyyyyy-0976 commented 1 year ago

download links libs - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a.tar.gz c++ includes - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sources/cxx-stl/gnu-libstdc++/4.9/include.tar.gz c includes - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sysroot/usr/include.tar.gz

ElectricPulse commented 12 months ago

Would you elaborate on your answer? What are these files? How does the NDK relate to this problem?

download links libs - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a.tar.gz c++ includes - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sources/cxx-stl/gnu-libstdc++/4.9/include.tar.gz c includes - https://chromium.googlesource.com/android_ndk/+archive/refs/heads/r16/sysroot/usr/include.tar.gz

yyyyyy-0976 commented 11 months ago

Android dropped support for gcc from ndk r18 thats why i am using a older ndk.

The container compressed folders which contain header files for c and c++ and libraries .

Decompress the files files using zarchiver then on termux use CD to navigate to one of the folder with c headers then go to bits and move all the files from there to $PREFIX/includes/bits then exit the bits directory then remove bits and copy all the folders and header files inside the folder to $PREFIX/includes. Repeat the steps for the second folder with c++ headers . Goto the folder containing libraries and move libgnustl_shared to $PREFIX/lib .

Now you can compile c programs with gcc file.c and c++ programs with g++ file.cpp -lgnustl_shared .

martin-frbg commented 9 months ago

See #141 for what needs to be edited to get rid of the undefined "INTRODUCED_IN" in the standard headers

the-loan-wolf commented 3 months ago

This issue is due to failing of setup-patchforgcc script. If you run it with -v flag, you will find these errors

patching file include/sys/cdefs.h                                                                                     Reversed (or previously applied) patch detected!  Skipping patch.                                                     2 out of 2 hunks ignored -- saving rejects to file include/sys/cdefs.h.rej                                            patching headers with /data/data/com.termux/files/usr/share/setup_scripts/cdefs.h-gcc-compat.diff                     patching file include/bits/fortify/fcntl.h                                                                            Reversed (or previously applied) patch detected!  Skipping patch.                                                     2 out of 2 hunks ignored -- saving rejects to file include/bits/fortify/fcntl.h.rej                                   patching file include/bits/fortify/poll.h
Hunk #1 FAILED at 44.
Hunk #2 FAILED at 89.                                                                                                 2 out of 2 hunks FAILED -- saving rejects to file include/bits/fortify/poll.h.rej
patching file include/bits/fortify/socket.h
Hunk #1 FAILED at 47.
Hunk #2 FAILED at 94.
2 out of 2 hunks FAILED -- saving rejects to file include/bits/fortify/socket.h.rej
patching file include/bits/fortify/stat.h
Hunk #1 FAILED at 39.
Hunk #2 FAILED at 50.
2 out of 2 hunks FAILED -- saving rejects to file include/bits/fortify/stat.h.rej
patching file include/bits/fortify/stdio.h
Reversed (or previously applied) patch detected!  Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file include/bits/fortify/stdio.h.rej
patching file include/bits/fortify/stdlib.h
Hunk #1 FAILED at 37.
1 out of 1 hunk FAILED -- saving rejects to file include/bits/fortify/stdlib.h.rej
patching file include/bits/fortify/string.h
Hunk #1 FAILED at 52.
Hunk #2 FAILED at 112.
Hunk #3 FAILED at 238.
3 out of 3 hunks FAILED -- saving rejects to file include/bits/fortify/string.h.rej
patching file include/bits/fortify/unistd.h
Reversed (or previously applied) patch detected!  Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file include/bits/fortify/unistd.h.rej
patching file include/bits/ioctl.h
Reversed (or previously applied) patch detected!  Skipping pat
ch.
1 out of 1 hunk ignored -- saving rejects to file include/bits/ioctl.h.rej
patching file include/complex.h
Reversed (or previously applied) patch detected!  Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/complex.h.rej
patching file include/stdatomic.h
Hunk #1 FAILED at 33.
Hunk #2 FAILED at 146.
Hunk #3 FAILED at 185.
Hunk #4 FAILED at 235.
Hunk #5 FAILED at 301.
Hunk #6 FAILED at 325.
Hunk #7 FAILED at 352.
Hunk #8 FAILED at 366.
8 out of 8 hunks FAILED -- saving rejects to file include/stdatomic.h.rej
patching file include/string.h
Reversed (or previously applied) patch detected!  Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file include/string.h.rej
patching file include/sys/cdefs.h
Reversed (or previously applied) patch detected!  Skipping patch.
7 out of 7 hunks ignored -- saving rejects to file include/sys/cdefs.h.rej
patching file include/sys/mman.h
Hunk #1 FAILED at 56.
1 out of 1 hunk FAILED -- saving rejects to file include/sys/mman.h.rej
patching headers with /data/data/com.termux/files/usr/share/setup_scripts/gcc_fixes.diff