tcc官网:
下载地址:
http://download.savannah.gnu.org/releases/tinycc/
termux纯命令行编译过程及一些问题
pkg install wget -y
wget http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27.tar.bz2
tar -jxvf tcc-0.9.27.tar.bz2
cd tcc-0.9.27
./configure
至此,第一个坑出现了,Vim到配置文件
vim config.mak
内容:
prefix=/usr/local
bindir=$(DESTDIR)/usr/local/bin
tccdir=$(DESTDIR)/usr/local/lib/tcc
libdir=$(DESTDIR)/usr/local/lib
includedir=$(DESTDIR)/usr/local/include
mandir=$(DESTDIR)/usr/local/share/man
infodir=$(DESTDIR)/usr/local/share/info
docdir=$(DESTDIR)/usr/local/share/doc
CC=gcc
GCC_MAJOR=4 GCC_MINOR=2 AR=ar
STRIP=strip -s -R .comment -R .note
CFLAGS=-Wall -g -O2 -Wdeclaration-after-statement -fno
-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -
Wno-unused-result LDFLAGS= LIBSUF=.a EXESUF=
DLLSUF=.so
ARCH=arm
TARGETOS=Linux
CONFIG_arm_vfp=yes
VERSION = 0.9.27
TOPSRC=$(TOP)
坑在于termux的usr目录下没有local目录,需要删去local:
# Automatically generated by configure - do not modify
prefix=/usr
bindir=$(DESTDIR)/usr/bin
tccdir=$(DESTDIR)/usr/lib/tcc
libdir=$(DESTDIR)/usr/lib
includedir=$(DESTDIR)/usr/include
mandir=$(DESTDIR)/usr/share/man
infodir=$(DESTDIR)/usr/share/info docdir=$(DESTDIR)/usr/share/doc CC=gcc
GCC_MAJOR=4 GCC_MINOR=2 AR=ar
STRIP=strip -s -R .comment -R .note
CFLAGS=-Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result LDFLAGS= LIBSUF=.a EXESUF=
DLLSUF=.so
ARCH=arm
TARGETOS=Linux
CONFIG_arm_vfp=yes
VERSION = 0.9.27
TOPSRC=$(TOP)
这样就好了,继续。
安装编译环境:
pkg install clang binutils texinfo proot -y
之后就是make了,但第二个问题出现了!
pkg install make -y && make
报错:
tccpp.c:1421:33: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
fprintf(s->ppfp, "\n[%s]\n" + !(s->dflag & 32), p), fflush(s->ppfp);
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
tccpp.c:1421:33: note: use array indexing to silence this warning
fprintf(s->ppfp, "\n[%s]\n" + !(s->dflag & 32), p), fflush(s->ppfp);
^
& [ ]
tccpp.c:3723:20: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
fprintf(fp, " %s" + s, get_tok_str(t, &cval)), s = 1;
~~~~~~^~~
tccpp.c:3723:20: note: use array indexing to silence this warning
fprintf(fp, " %s" + s, get_tok_str(t, &cval)), s = 1;
^
& [ ]
2 warnings generated.
大概是作者想要把数字拼接到字符上去,结果直接写了,我不了解其他的C语言标准可不可以这么做,但显然这里要人工处理一下,加个"%d"然后改一下参数顺序就好了。
fprintf(s->ppfp, "\n[%s]\n%d",p,!(s->dflag & 32)), fflush(s->ppfp);
fprintf(fp, " %s%d",get_tok_str(t, &cval),s), s = 1;
然后再make。
之后是最后一个坑:
安装时必须要在root环境,但装好后不用root。
make
termux-chroot
make install
exit
就安装好了。