ndk에 있는 툴체인으로 gcc를 컴파일 하고 있습니다.
글쓴이: pillose / 작성시간: 월, 2018/01/08 - 1:14오후
루팅된 핸드폰에서 gcc를 사용하고 싶어서 크로스 컴파일러로 직접 컴파일 하고 있습니다.그런데 처음에는 그냥 '명령어 몇 개 입력하면 컴퓨터가 알아서 하겠지' 라는 생각으로 시작을 했는데 계속 오류가 납니다.인터넷을 뒤져봐도 해결책을 찾을 수 없어서 이 글을 씁니다.
혹시나 해서 두 가지 버전을 컴파일 하고 있습니다.
gcc-4.8.0은
make[2]: Entering directory `/home/pillose/gcc/gcc-4.8.0/objdir/gcc' g++ -c -pie -fPIC -D__ANDROID_API__=21 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I.././../gcc -I.././../gcc/build -I.././../gcc/../include -I./../intl -I.././../gcc/../libcpp/include -I.././../gcc/../libdecnumber -I.././../gcc/../libdecnumber/dpd -I../libdecnumber -I.././../gcc/../libbacktrace \ -o build/genconstants.o .././../gcc/genconstants.c In file included from .././../gcc/genconstants.c:28:0: .././../gcc/system.h:444:23: error: declaration of C function ‘void* sbrk(int)’ conflicts with extern void *sbrk (int); ^ In file included from .././../gcc/system.h:254:0, from .././../gcc/genconstants.c:28: /usr/include/unistd.h:1043:14: error: previous declaration ‘void* sbrk(intptr_t)’ here extern void *sbrk (intptr_t __delta) __THROW; ^ In file included from .././../gcc/genconstants.c:28:0: .././../gcc/system.h:448:48: error: new declaration ‘char* strstr(const char*, const char*)’ extern char *strstr (const char *, const char *); ^ In file included from /usr/local/include/c++/4.8.0/cstring:42:0, from .././../gcc/system.h:205, from .././../gcc/genconstants.c:28: /usr/include/string.h:324:20: error: ambiguates old declaration ‘const char* strstr(const char*, const char*)’ extern const char *strstr (const char *__haystack, const char *__needle) ^ In file included from .././../gcc/genconstants.c:28:0: .././../gcc/system.h:500:34: error: declaration of C function ‘const char* strsignal(int)’ conflicts with extern const char *strsignal (int); ^ In file included from /usr/local/include/c++/4.8.0/cstring:42:0, from .././../gcc/system.h:205, from .././../gcc/genconstants.c:28: /usr/include/string.h:564:14: error: previous declaration ‘char* strsignal(int)’ here extern char *strsignal (int __sig) __THROW; ^ In file included from .././../gcc/system.h:645:0, from .././../gcc/genconstants.c:28: .././../gcc/../include/libiberty.h:110:36: error: new declaration ‘char* basename(const char*)’ extern char *basename (const char *); ^ In file included from /usr/local/include/c++/4.8.0/cstring:42:0, from .././../gcc/system.h:205, from .././../gcc/genconstants.c:28: /usr/include/string.h:601:26: error: ambiguates old declaration ‘const char* basename(const char*)’ extern "C++" const char *basename (const char *__filename) ^ make[2]: *** [build/genconstants.o] 오류 1 make[2]: Leaving directory `/home/pillose/gcc/gcc-4.8.0/objdir/gcc' make[1]: *** [all-gcc] 오류 2 make[1]: Leaving directory `/home/pillose/gcc/gcc-4.8.0/objdir' make: *** [all] 오류 2 pillose@pillose-ubuntu:~/gcc/gcc-4.8.0/objdir$
이렇게 나오고
gcc-6.3.0은
make[2]: Entering directory `/home/pillose/gcc/gcc-6.3.0/objdir/intl' rm -f stamp-h1 /bin/bash ./config.status config.h config.status: creating config.h config.status: config.h is unchanged test -f config.h || (rm -f stamp-h1 && make stamp-h1) arm-linux-androideabi-gcc -c -pie -fPIC -D__ANDROID_API__=21 -DHAVE_CONFIG_H -I. -I.././../intl plural.c In file included from .././../intl/plural.y:35:0: .././../intl/plural-exp.h:102:23: error: conflicting types for 'libintl_gettextparse' # define PLURAL_PARSE libintl_gettextparse ^ .././../intl/plural.y:40:25: note: in expansion of macro 'PLURAL_PARSE' # define __gettextparse PLURAL_PARSE ^ plural.c:182:5: note: in expansion of macro '__gettextparse' int __gettextparse (void); ^ .././../intl/plural-exp.h:102:23: note: previous declaration of 'libintl_gettextparse' was here # define PLURAL_PARSE libintl_gettextparse ^ .././../intl/plural-exp.h:114:12: note: in expansion of macro 'PLURAL_PARSE' extern int PLURAL_PARSE PARAMS ((void *arg)); ^ .././../intl/plural-exp.h:102:23: error: conflicting types for 'libintl_gettextparse' # define PLURAL_PARSE libintl_gettextparse ^ .././../intl/plural.y:40:25: note: in expansion of macro 'PLURAL_PARSE' # define __gettextparse PLURAL_PARSE ^ plural.c:63:25: note: in expansion of macro '__gettextparse' #define yyparse __gettextparse ^ plural.c:1127:1: note: in expansion of macro 'yyparse' yyparse (void) ^ .././../intl/plural-exp.h:102:23: note: previous declaration of 'libintl_gettextparse' was here # define PLURAL_PARSE libintl_gettextparse ^ .././../intl/plural-exp.h:114:12: note: in expansion of macro 'PLURAL_PARSE' extern int PLURAL_PARSE PARAMS ((void *arg)); ^ plural.c: In function 'libintl_gettextparse': plural.c:64:25: error: too few arguments to function '__gettextlex' #define yylex __gettextlex ^ plural.c:1296:16: note: in expansion of macro 'yylex' yychar = yylex (&yylval); ^ plural.c:64:25: note: declared here #define yylex __gettextlex ^ .././../intl/plural.y:69:12: note: in expansion of macro 'yylex' static int yylex PARAMS ((YYSTYPE *lval, const char **pexp)); ^ .././../intl/plural.y:178:29: error: 'arg' undeclared (first use in this function) ((struct parse_args *) arg)->res = $1; ^ .././../intl/plural.y:178:29: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [plural.o] 오류 1 make[2]: Leaving directory `/home/pillose/gcc/gcc-6.3.0/objdir/intl' make[1]: *** [all-intl] 오류 2 make[1]: Leaving directory `/home/pillose/gcc/gcc-6.3.0/objdir' make: *** [all] 오류 2 pillose@pillose-ubuntu:~/gcc/gcc-6.3.0/objdir$
이렇게 나옵니다.
아마 컴파일러 문제 같은데 어떻게 해야 할지 모르겠습니다.
ndk는 https://developer.android.com/ndk/downloads/index.html?hl=ko 여기서 받았고
configure 옵션은
--prefix=/data/gcc --host=arm-linux-androideabi --target=arm-linux-androideabi CFLAGS="-pie -fPIC -D__ANDROID_API__=21" CXXFLAGS="-pie -fPIC -D__ANDROID_API__=21"
이렇습니다.답변이 달리길 기대하겠습니다...
Forums:
그냥 ARM용 gcc 다운받아서 쓰시면 되지 않나요?
그냥 ARM용 gcc 다운받아서 쓰시면 되지 않나요?
이 문제 아닌가요?
구글 검색해 보니
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59217
이게 나오는데
"on the build machine was a side-effect of not having GMP/MPFR/MPC available for the build machine"
이라고 나오는군요.
컴파일러 컴파일 하는거, 상당히 터프한 일인데...
컴파일러 컴파일 하는거, 상당히 터프한 일인데...
기존 빌드된걸 받아쓰거나, buildroot/crosstoolng 등 관리되고 있는 컴파일러 빌드 스크립트를 사용하거나, 참고하시는게,,