【问题标题】:how to make executable(.exe) using arm-linux-androideabi-gcc?如何使用 arm-linux-androideabi-gcc 制作可执行文件(.exe)?
【发布时间】:2012-09-27 11:24:57
【问题描述】:

我有一个共享库,它使用 arm-linux-androideabi-gcc 编译器在 c 构建中编写,现在我想测试我的共享库,所以我编写了一个示例 c,它调用该共享库 (.so),我想make .exe ,所以当我编译时出现这样的错误 这是我的制作文件

      TARG_OS       = WIN32
BUILDTYPE     = Debug
OS_BITS = 32    

SRC     := TestLSBioCore.c 



OBJS = $(SRC:.c=.o)

OUT         = ./Test.exe

OUTLIB      = 

INCLUDE     = -I../../../../../../../android-ndk-r8b/platforms/android-8/arch-arm/usr/include -I../../include

LIBS        = libLSBioCore.so



# C++ compiler flags (-g -O2 -Wall)
#CCFLAGS    = -O2 -w -ansi -D_POSIX_SOURCE

CCFLAGS     = -O2 -w -D_POSIX_SOURCE

DEFS        =  "-D __MSYS__" "-D__NBISLE__"

#LDFLAGS 
CFLAGS = -nostdlib 
LDFLAGS =-Wl,-rpath-link=../../../../../../../android-ndk-r8b/platforms/android-8/arch-arm/usr/lib/ -L../../../../../../../android-ndk-r8b/platforms/android-8/arch-arm/usr/lib/
LIB = -lc -lm

OBJECT = ../../../../../../../android-ndk-r8b/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o \
../../../../../../../android-ndk-r8b/platforms/android-8/arch-arm/usr/lib/crtend_android.o




#compiler
#CCC        = mingw32-gcc

CCC         = arm-linux-androideabi-gcc

#Archive
#AR = ar
#AR = /cygdrive/f/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-ar

AR = arm-linux-androideabi-ar
.SUFFIXES: .c

default: dep $(OUT)

.c.o:
    $(CCC) -c $(CCFLAGS) $(INCLUDE) $(DEFS)  $< -o $@

$(OUT): $(OBJS) 
    $(CCC) -o $(OUT) $(OBJECT) $(OBJS) $(LIBS) $(CFLAGS) $(LDFLAGS) $(LIB)
    #$(AR) rcs $(OUTLIB) $(OBJS)
    rm -f $(OBJS)

depend: dep

dep:
#   makedepend -- $(CFLAGS) -- $(INCLUDES) $(SRC)

clean:
    del  $(OBJS) $(OUT)

我收到以下错误

        libLSBioCore.so: undefined reference to `__aeabi_dcmple'
        libLSBioCore.so: undefined reference to `__aeabi_fadd'
        libLSBioCore.so: undefined reference to `__aeabi_fcmpgt'
        libLSBioCore.so: undefined reference to `__aeabi_i2f'
        libLSBioCore.so: undefined reference to `__aeabi_dcmplt'
        libLSBioCore.so: undefined reference to `__aeabi_ddiv'
        libLSBioCore.so: undefined reference to `__aeabi_dmul'
        libLSBioCore.so: undefined reference to `__aeabi_d2f'
        libLSBioCore.so: undefined reference to `__aeabi_fsub'
        libLSBioCore.so: undefined reference to `__aeabi_fcmpge'
        libLSBioCore.so: undefined reference to `__aeabi_dadd'
        libLSBioCore.so: undefined reference to `__aeabi_idiv'
        libLSBioCore.so: undefined reference to `__aeabi_dcmpgt'
        libLSBioCore.so: undefined reference to `__aeabi_dcmpge'
        libLSBioCore.so: undefined reference to `__aeabi_dsub'
        libLSBioCore.so: undefined reference to `__aeabi_f2iz'
        libLSBioCore.so: undefined reference to `__aeabi_fdiv'
        libLSBioCore.so: undefined reference to `__aeabi_i2d'
        libLSBioCore.so: undefined reference to `__aeabi_fcmpeq'
        libLSBioCore.so: undefined reference to `__aeabi_fmul'
        libLSBioCore.so: undefined reference to `__aeabi_fcmplt'
        libLSBioCore.so: undefined reference to `__aeabi_dcmpeq'
        libLSBioCore.so: undefined reference to `__aeabi_f2uiz'
        libLSBioCore.so: undefined reference to `__aeabi_d2iz'
        libLSBioCore.so: undefined reference to `__aeabi_f2d'
        libLSBioCore.so: undefined reference to `__aeabi_idivmod'
        collect2: ld returned 1 exit status
        Makefile:57: recipe for target `Test.exe' failed

我希望我在我的 make 中给出了正确的链接,我不知道这背后的错误是什么,有人知道如何使用 arm-linux-androideabi-gcc 制作 exe。

【问题讨论】:

  • 郑重声明,它不会是 .exe。根据 Linux 约定,它将是一个独立的可执行文件,但没有任何扩展名。

标签: android android-ndk android-ndk-r5 android-ndk-r7


【解决方案1】:

你选择了一条复杂的路;请注意,使用ndk-build,您可以更轻松地构建可执行文件。例如,查看 test-libstdc++ NDK 示例。

但也可以使用 ma​​ke。但是,当您在命令行上设置 -nostdlib 时,您需要更多的库。

添加-lgcc。您可能需要来自toolchains/arm-linux-androideabi-4.6/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.6.x-google 的更多库以满足更多引用。

【讨论】:

    猜你喜欢
    • 2012-09-13
    • 1970-01-01
    • 2011-12-23
    • 2016-03-02
    • 1970-01-01
    • 2015-03-30
    • 2016-04-30
    • 2014-10-31
    • 1970-01-01
    相关资源
    最近更新 更多