Closed AG-7219 closed 2 years ago
Hi! Also want to add my issue since it is related : I'm just trying to compile "Hello world" program with gcc-11 but got
~ $ gcc hello1.c
In file included from /data/data/com.termux/files/usr/include/sys/cdefs.h:370,
from /data/data/com.termux/files/usr/include/stdio.h:41,
from hello1.c:1:
/data/data/com.termux/files/usr/include/android/api-level.h:174:50: error: 'stric' undeclared here (not in a function)
174 | int android_get_application_target_sdk_version() __INTRODUCED_IN(24);
| ^~~~~~~~~~~~~~~
/data/data/com.termux/files/usr/include/android/api-level.h:174:50: error: 'introduced' undeclared here (not in a function)
174 | int android_get_application_target_sdk_version() __INTRODUCED_IN(24);
| ^~~~~~~~~~~~~~~
No problem at all with clang. Android 11 & Termux 0.118.0
Maybe you could try to pass -D__BIONIC_VERSIONER
, like gcc main.c -o output -D__BIONIC_VERSIONER
.
@licy183 thanks for your response. Using the flag indeed removed the previous errors, though I still get some errors.
Update : it seems like there is already a fix for the errors that I encountered after using the flag, all i had to do was execute the command setup-patchforgcc
and everything worked. @T-3B can you please confirm if the same works for you as well so that i can close the issue. Also, thanks again @licy183.
I confirm @AG-7219 !
The D__BIONIC_VERSIONER
did change the errors, while setup-patchgcc
did correct them!
No more error at all.
Thank you to both of you ^^
Update
Actually even after setup-patchgcc
I need to specify D__BIONIC_VERSIONER
to compile successfully (but needed them both).
Not sure if this project still has a maintainer, but if it does, the fix should be as simple as having the setup-patchforgcc script add
#if !defined(__clang__)
#define __BIONIC_VERSIONER
#endif
after the "#pragma once" line in /usr/include/android/versioning.h
EDIT: or put the attached file (without the final ".txt" extension added for the github UI) in /usr/share/setup-scripts before running setup-patchforgcc . Doing a PR here appears to be, well, pointless, as the script and its patch files appear to be part of the binary .deb package for gcc in the "pointless" repo versioning-gcc-compat.diff.txt
I installed both g++-10 and g++-11, but when I try to compile c++ code with these compilers i get a bunch of errors which seem to point towards problems in header files. The complete log is too large but I am attaching a snapshot for reference.
The installation of g++ was successful as can be seen from the g++ --version execution
These are the contents of the file that I am compiling
My device is poco M3 pro Android Version - 11 RP1A.200720.011 Termux Version - 0.118.0
Lastly, i was not getting these errors when i was using clang for compiling c++ files. Maybe the installation of gcc has some problems. I tried searching the errors on Google but couldn't find anything close the error message that I am getting. Thanks in advance for the help