chroot 환경의 armv6 안드로이드 폰에 Linux를 설치했습니다.
나는 설치했다musl-libc 라이브러리Android용 정적 바이너리 빌드의 소스 코드입니다. 이것은 데비안에서 빌드하고 설치할 때 실행하는 명령입니다.
./configure --disable-shared
make
make install
config.mak::입니다.
# This version of config.mak was generated by:
# ./configure --disable-shared
# Any changes made here will be lost if configure is re-run
ARCH = arm
SUBARCH =
ASMSUBARCH = el
prefix = /usr/local/musl
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
syslibdir = /lib
CC = gcc
CFLAGS = -Os -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack -Werror=implicit-function-declaration -$
CFLAGS_C99FSE = -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math
CFLAGS_MEMOPS = -fno-tree-loop-distribute-patterns
CPPFLAGS =
LDFLAGS = -Wl,--hash-style=both
CROSS_COMPILE =
LIBCC = -lgcc -lgcc_eh
OPTIMIZE_GLOBS = internal/*.c malloc/*.c string/*.c
SHARED_LIBS =
오류 없이 잘 빌드되고 설치됩니다.
하지만 설치를 확인할 때.
cat > hello.c <<EOF
#include <stdio.h>
int main()
{ printf("hello, world!\n");
return 0;
}
EOF
/usr/local/musl/bin/musl-gcc hello.c
./a.out
이 오류가 표시됩니다::
/usr/lib/gcc/arm-linux-gnueabi/4.6/libgcc.a(_dvmd_lnx.o): In function `__aeabi_ldiv0':
(.text+0x8): undefined reference to `raise'
collect2: ld returned 1 exit status
musl 설치에 어떤 문제가 있나요?
답변1
musl 지원팀으로부터 다음과 같은 답변을 받았습니다.
If you add -v, you should see
.. --start-group -lgcc -lgcc_eh -lc --end-group ..
which means all dependencies between libgcc and libc are resolved. I think gcc does not do the --start-group/--end-group without explicit -static, so only musl-gcc -static hello.c would work.
raise is in libc, referenced from libgcc
__aebi_ldiv0 is in libgcc, referenced from libc with static linking, undefined symbol resolution happens in the order the libraries are listed on the command line (so you need -lgcc -lc -lgcc -lc or the --*-group linker flags to resolve circular deps)
그래서 컴파일할 때 -static 플래그를 사용해야 합니다.