在android中编译本机代码。错误:对'main'的未定义引用

时间:2018-05-24 12:40:01

标签: android windows android-ndk java-native-interface native

我想在Android中用NDK构建器编译delegate(在windows中)。

DeleGate是一个多用途代理服务器,用于在多个平台上运行的多个应用程序协议。本文档的目的是通过一组使用示例和初学者的简短教程介绍如何使用DeleGate。

我是NDK的新手,任何线索都会有所帮助。

以下是竞争错误:

[armeabi-v7a] Executable     : delegated
D:/dev/sdk/android/ndk-bundle-r15b/build//../platforms/android-16/arch-arm/usr/lib/../lib\crtbegin_dynamic.o:crtbegin_dynamic.c:function _start: error: undefined reference to 'main'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [D:/dev_app/android-ndk-master/test-jni2/obj/local/armeabi-v7a/delegated] Error 1

这是Application.mk的内容

APP_ABI := armeabi-v7a x86 arm64-v8a
APP_PLATFORM := android-16
APP_OPTIM := release

这是Android.mk的内容

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := delegated

LOCAL_C_INCLUDES := \
    $(LOCAL_PATH) \
    $(LOCAL_PATH)/filters \
    $(LOCAL_PATH)/fsx \
    $(LOCAL_PATH)/gates \
    $(LOCAL_PATH)/include \
    $(LOCAL_PATH)/include-ce \
    $(LOCAL_PATH)/maker \
    $(LOCAL_PATH)/mimekit \
    $(LOCAL_PATH)/pds/md5 \
    $(LOCAL_PATH)/pds/regex \
    $(LOCAL_PATH)/rary \
    $(LOCAL_PATH)/resolvy \
    $(LOCAL_PATH)/subin \
    $(LOCAL_PATH)/teleport \
    $(LOCAL_PATH)/src \

LOCAL_SRC_FILES := \
#   filters/backup.c \
    filters/bdtee.c \
    filters/bdthru.c \
    filters/cafe.c \
    filters/cafemain.c \
    filters/cfi.c \
    filters/ciicgi.c \
    filters/dglogs.c \
    filters/dl.c \
    filters/dping.c \
    filters/expired.c \
    filters/fcl.c \
    filters/gzip.c \
    filters/htview.c \
    filters/htwrap.c \
    filters/m17nccx.c \
    filters/mkstab.c \
    filters/netzip.c \
    filters/pdft.c \
    filters/reclog.c \
    filters/regex.c \
    filters/sslway.c \
    filters/swft.c \
    fsx/any2fdif.c \
    gates/b2x.c \
    gates/Gates_Win32.c \
    maker/alloca.c \
    maker/avail.c \
    maker/bcopy.c \
    maker/bzero.c \
    maker/chown.c \
    maker/chroot.c \
    maker/closesocket.c \
    maker/dlopen.c \
    maker/dummy.c \
    maker/endhostent.c \
    maker/errno.c \
    maker/ERR_error_string_n.c \
    maker/fchmod.c \
    maker/fchown.c \
    maker/fcloseFILE.c \
    maker/fgetpos.c \
    maker/flockfile.c \
    maker/FMODE.c \
    maker/fork.c \
    maker/forkpty.c \
    maker/forkpty1.c \
    maker/fpurge.c \
    maker/fseeko.c \
    maker/fsync.c \
    maker/futimes.c \
    maker/futimes_.c \
    maker/Gates_Win32.c \
    maker/getcwd.c \
    maker/gethostbyname2.c \
    maker/gethostid.c \
    maker/getmsg.c \
    maker/getrlimit.c \
    maker/getrusage.c \
    maker/getwd.c \
    maker/getwinsize.c \
    maker/gxx.c \
    maker/inet_aton.c \
    maker/killpg.c \
    maker/link.c \
    maker/lstat.c \
    maker/malloc_size.c \
    maker/mkfifo.c \
    maker/mkmake.c \
    maker/mutex.c \
    maker/netsh_none.c \
    maker/nice.c \
    maker/nothread.c \
    maker/old_alloca.c \
    maker/opt_s_caps.c \
    maker/opt_s_htaccept.c \
    maker/opt_s_pilsner.c \
    maker/opt_s_sox.c \
    maker/opt_s_spinach.c \
    maker/opt_s_stls.c \
    maker/opt_s_vsap.c \
    maker/p2i.c \
    maker/p2ll.c \
    maker/pam_start.c \
    maker/pendingcc.c \
    maker/pendingcc1.c \
    maker/pthread_kill.c \
    maker/ptrace.c \
    maker/putenv.c \
    maker/readlink.c \
    maker/regex.c \
    maker/RSA_generate_key.c \
    maker/sendFd1.c \
    maker/sendFd2.c \
    maker/sendFd3.c \
    maker/setbuffer.c \
    maker/setegid.c \
    maker/seteuid.c \
    maker/setferror.c \
    maker/setlinebuf.c \
    maker/setlogin.c \
    maker/setproctitle.c \
    maker/setresuid.c \
    maker/setsid.c \
    maker/sgTTy.c \
    maker/sigaction.c \
    maker/sigmask.c \
    maker/sigsetmask.c \
    maker/snprintf.c \
    maker/socketpair.c \
    maker/socklen_s.c \
    maker/socklen_u.c \
    maker/spawnvp.c \
    maker/spawnvp_.c \
    maker/SSL_CTX_set_tmp_rsa_callback.c \
    maker/SSL_library_init.c \
    maker/SSL_set_SSL_CTX.c \
    maker/statvfs.c \
    maker/stdio.c \
    maker/strcasecmp.c \
    maker/strcasestr.c \
    maker/strdup.c \
    maker/strerror.c \
    maker/strncpy.c \
    maker/strrcasestr.c \
    maker/strstr.c \
    maker/Stty.c \
    maker/symlink.c \
    maker/sysctl.c \
    maker/sysctlbyname.c \
    maker/sysinfo.c \
    maker/syslog.c \
    maker/timegm.c \
    maker/ualarm.c \
    maker/unaligned.c \
    maker/uname.c \
    maker/unsetenv.c \
    maker/unsetenv_.c \
    maker/usleep.c \
    maker/utimes.c \
    maker/vfork.c \
    maker/wait3.c \
    maker/waitpid.c \
    maker/yp_match.c \
    maker/_-fcloseFILE.c \
    maker/_-fcloseFILE2.c \
    maker/_-fcntl.c \
    maker/_-fgetpos.c \
    maker/_-forkpty.c \
    maker/_-fseeko.c \
    maker/_-getrusage.c \
    maker/_-mkfifo.c \
    maker/_-mutex.c \
    maker/_-poll.c \
    maker/_-poll1.c \
    maker/_-poll2.c \
    maker/_-pthread_create.c \
    maker/_-ptrace.c \
    maker/_-recv.c \
    maker/_-regex.c \
    maker/_-select.c \
    maker/_-setferror.c \
    maker/_-sgTTy.c \
    maker/_-statvfs.c \
    maker/_-strcasestr.c \
    maker/_-sysconf.c \
    maker/_-sysconf2.c \
    maker/_-sysinfo.c \
    maker/_-system.c \
    maker/_spawnvp.c \
    maker/__alloca.c \
    maker/__fchmod.c \
    maker/__fchown.c \
    maker/__flock.c \
    maker/__fork.c \
    maker/__forkpty.c \
    maker/__futimes.c \
    maker/__gethostbyname2.c \
    maker/__getrlimit.c \
    maker/__getwinsize.c \
    maker/__link.c \
    maker/__lstat.c \
    maker/__lwp_create.c \
    maker/__malloc_size.c \
    maker/__opendir.c \
    maker/__pthread_create.c \
    maker/__pthread_kill.c \
    maker/__ptrace.c \
    maker/__scandir.c \
    maker/__setproctitle.c \
    maker/__sigaction.c \
    maker/__spawnvp.c \
    maker/__statvfs.c \
    maker/__symlink.c \
    maker/__syscall.c \
    maker/__sysconf.c \
    maker/__sysctl.c \
    maker/__sysinfo.c \
    maker/__syslog.c \
    maker/__system.c \
    maker/__tcsetattr.c \
    maker/__ualarm.c \
    maker/__uname.c \
    maker/__usleep.c \
    maker/__utimes.c \
    maker/___beginthread.c \
    maker/___lwp_create.c \
    maker/___spawnvp.c \
    mimekit/gendom.c \
    mimekit/mime.c \
    mimekit/mimecodes.c \
    mimekit/mimeconv.c \
    mimekit/mimehead.c \
    mimekit/mimeh_ovw.c \
    mimekit/mimemain.c \
    mimekit/noxlib.c \
    mimekit/pgp.c \
    mimekit/rfc822.c \
    mimekit/str_codes.c \
    pds/md5/md5c.c \
    pds/md5/md5cb.c \
    pds/md5/md5lib.c \
    pds/md5/md5main.c \
    pds/md5/mddriver.c \
    pds/regex/engine.c \
    pds/regex/regcomp.c \
    pds/regex/regdummy.c \
    pds/regex/regerror.c \
    pds/regex/regexec.c \
    pds/regex/regfree.c \
    rary/asock.c \
    rary/bsort.c \
    rary/ccx.c \
    rary/ccxmain.c \
    rary/cfilib.c \
    rary/cksum.c \
    rary/codec.c \
    rary/codeconv.c \
    rary/credhy.c \
    rary/dglibs.c \
    rary/file.c \
    rary/Finish.c \
    rary/forkspawn.c \
    rary/fpoll.c \
    rary/fpolls.c \
    rary/frelay.c \
    rary/fstat.c \
    rary/hash.c \
    rary/hostaddr.c \
    rary/html.c \
    rary/IsSolaris.c \
    rary/JIS.c \
    rary/libpam.c \
    rary/lock.c \
    rary/lsock.c \
    rary/modfmt.c \
    rary/nbio.c \
    rary/netsh.c \
    rary/pam.c \
    rary/passwd.c \
    rary/pelcgb.c \
    rary/pilsner.c \
    rary/pstitle.c \
    rary/randstack.c \
    rary/rawcopy.c \
    rary/readycc.c \
    rary/sched.c \
    rary/schedmain.c \
    rary/sed.c \
    rary/setutimes.c \
    rary/signal.c \
    rary/SLL.c \
    rary/socks5.c \
    rary/Strftime.c \
    rary/strid.c \
    rary/String.c \
    rary/str_stdio.c \
    rary/syslog.c \
    rary/tar.c \
    rary/Thread.c \
    rary/Timeofday.c \
    rary/timer.c \
    rary/TLEX.c \
    rary/unix.c \
    rary/urlesc.c \
    rary/uu.c \
    rary/vsaddr.c \
    rary/wince.c \
    rary/windows.c \
    rary/windows0.c \
    rary/winmisc.c \
    rary/winmo.c \
    rary/winnat.c \
    rary/winsspi.c \
    rary/ystring.c \
    resolvy/dnsnode.c \
    resolvy/hostent.c \
    resolvy/ntod.c \
    resolvy/rescache.c \
    resolvy/resconf.c \
    resolvy/reshost.c \
    resolvy/resmain.c \
    resolvy/resolv.c \
    subin/dgbind.c \
    subin/dgchroot.c \
    subin/dgcpnod.c \
    subin/dgdate.c \
    subin/dgforkpty.c \
    subin/dgpam.c \
    subin/dgsetlogin.c \
    subin/dgxauth.c \
    include/mkcpp.c \
#   include/typedefs.c \
    src/abort.c \
    src/access.c \
    src/admin.c \
    src/alias.c \
    src/bcounter.c \
    src/builtin.c \
    src/cache.c \
    src/caps.c \
    src/ccache.c \
    src/cgi.c \
    src/commands.c \
    src/cond.c \
    src/conf.c \
    src/coupler.c \
    src/croncom.c \
    src/cuseeme.c \
    src/db.c \
    src/ddi.c \
    src/delegated.c \
    src/dgauth.c \
    src/dget.c \
    src/dgsign.c \
    src/distrib.c \
    src/domain.c \
    src/dtot.c \
    src/editconf.c \
    src/embed.c \
    src/enews.c \
    src/env.c \
    src/filetype.c \
    src/filter.c \
    src/form2conf.c \
    src/ftp.c \
    src/ftpgw.c \
    src/gacl.c \
    src/gopher.c \
    src/hostlist.c \
    src/htaccept.c \
    src/htccx.c \
    src/htfilter.c \
    src/htmlgen.c \
    src/htswitch.c \
    src/http.c \
    src/httpd.c \
    src/httphead.c \
    src/httplog.c \
    src/httpx.c \
    src/icap.c \
    src/icp.c \
    src/ident.c \
    src/imap.c \
    src/inetd.c \
    src/inets.c \
    src/inets_lib.c \
    src/iotimeout.c \
    src/ipno.c \
    src/ldap.c \
    src/log.c \
    src/lpr.c \
    src/master.c \
    src/misc.c \
    src/mkmkmk.c \
    src/mount.c \
    src/msg.c \
    src/nntp.c \
    src/nntpgw.c \
    src/nntplist.c \
    src/notify.c \
    src/param.c \
    src/pop.c \
    src/process.c \
    src/qstest.c \
    src/remote.c \
    src/rident.c \
    src/script.c \
    src/service.c \
    src/sftp.c \
    src/shio.c \
    src/shutter.c \
    src/smtp.c \
    src/smtpgate.c \
    src/smtp_lib.c \
    src/socks.c \
    src/socks4.c \
    src/sox.c \
    src/spinach.c \
    src/ssi.c \
    src/stls.c \
    src/sudo.c \
    src/svconf.c \
    src/svport.c \
    src/svstat.c \
    src/syslog.c \
    src/tcprelay.c \
    src/telnet.c \
    src/textconv.c \
    src/thmain.c \
    src/thruwayd.c \
    src/tsp.c \
    src/udprelay.c \
    src/uns.c \
    src/url.c \
    src/urlfind.c \
    src/utmpident.c \
    src/vaddr.c \
    src/version.c \
    src/vsap.c \
    src/wais.c \
    src/whois.c \
    src/X.c \
    src/xferlog.c \
    src/xflash.c \
    src/yshell.c \
    src/delegate.c \
    putsigned.c \
    srcsign.c \
    src-srcsign.c \
    mkmkmk.c 

LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -Doff64_t=_off64_t -DUSE_IPv6 -DHAVE_PTHREADS -DBISTSPEED

LOCAL_LDLIBS := -lz -llog

include $(BUILD_EXECUTABLE)

1 个答案:

答案 0 :(得分:0)

这不是NDK独有的:可执行文件需要具有main函数。您是否要构建库或可执行文件?对于NDK,您几乎总是需要一个库。为此,您应该使用BUILD_SHARED_LIBRARY而不是BUILD_EXECUTABLE。如果需要可执行文件,请添加一个main函数。