使用独立工具链为 android 构建 squid 时出现未定义引用错误
undefined reference error when using standalone toolchain to build squid for android
我正在尝试为 android 构建 squid-3.5.24。我正在使用 android-ndk-r10e
进行构建。
这是我的环境。基于此:https://gist.github.com/nddrylliog/4688209
#!/bin/sh
# I put all my dev stuff in here
export DEV_PREFIX=$HOME/Documents
# Don't forget to adjust this to your NDK path
export ANDROID_NDK=$HOME/Android/android-ndk-r10e
export CROSS_COMPILE=arm-linux-androideabi
# I chose the gcc-4.7 toolchain - works fine for me!
export ANDROID_PREFIX=$DEV_PREFIX/toolchain/arm-linux-androideabi-4.8
# Apparently android-8 works fine, there are other versions, look them up
export SYSROOT=${ANDROID_PREFIX}/sysroot
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}
# Non-exhaustive lists of compiler + binutils
# Depending on what you compile, you might need more binutils than that
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib
export PATH=$PATH:$ANDROID_PREFIX/bin
export PATH=$PATH:${SYSROOT}/usr/lib
# This is just an empty directory where I want the built objects to be installed
export PREFIX=${SYSROOT}
# Don't mix up .pc files from your host and build target
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
# You can clone the full Android sources to get bionic if you want.. I didn't
# want to so I just got linker.h from here: http://gitorious.org/0xdroid/bionic
# Note that this was only required to build boehm-gc with dynamic linking support.
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} --cache-file=squid.cache "$@"
configure
成功完成我 运行 make
。在编译过程中,我得到这个错误:
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
collect2: error: ld returned 1 exit status
make[3]: *** [basic_smb_lm_auth] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
我认为该错误与链接器无法定位 libstdc++
或 libstdc++--v3
有关,但这些库存在于 sysroot/usr/lib
中,已提供给 ld
.
我曾尝试将库直接与 -lstdc++--v3
和 -lstdc++
链接,但这似乎与配置中的 gcc
混淆。
目前我无能为力,任何人都可以指出正确的方向吗?
这是 make
的其余输出:
Making all in compat
make[1]: Nothing to be done for `all'.
Making all in lib
Making all in snmplib
make[2]: Nothing to be done for `all'.
Making all in rfcnb
make[2]: Nothing to be done for `all'.
Making all in smblib
make[2]: Nothing to be done for `all'.
Making all in ntlmauth
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
Making all in libltdl
/Library/Developer/CommandLineTools/usr/bin/make all-am
make[2]: Nothing to be done for `all-am'.
Making all in scripts
make[1]: Nothing to be done for `all'.
Making all in icons
make[1]: Nothing to be done for `all'.
Making all in errors
make[1]: Nothing to be done for `all'.
Making all in doc
Making all in manuals
make[2]: Nothing to be done for `all'.
Making all in release-notes
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
Making all in helpers
Making all in basic_auth
Making all in DB
make[3]: Nothing to be done for `all'.
Making all in MSNT-multi-domain
make[3]: Nothing to be done for `all'.
Making all in NCSA
make[3]: Nothing to be done for `all'.
Making all in POP3
make[3]: Nothing to be done for `all'.
Making all in RADIUS
make[3]: Nothing to be done for `all'.
Making all in SMB
make[3]: Nothing to be done for `all'.
Making all in SMB_LM
/bin/sh ../../../libtool --tag=CXX --mode=link /Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-g++ -g -O2 -std=c++11 -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/sysroot/usr/lib -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/lib -o basic_smb_lm_auth msntauth.o valid.o ../../../lib/smblib/libsmblib.la ../../../lib/rfcnb/librfcnb.la ../../../lib/libmiscencoding.la ../../../compat/libcompat-squid.la -lm
libtool: link: /Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-g++ -g -O2 -std=c++11 -o basic_smb_lm_auth msntauth.o valid.o -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/sysroot/usr/lib -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/lib ../../../lib/smblib/.libs/libsmblib.a ../../../lib/rfcnb/.libs/librfcnb.a ../../../lib/.libs/libmiscencoding.a ../../../compat/.libs/libcompat-squid.a -lm
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::__throw_bad_cast()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::cerr'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:152: error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.o(.ARM.extab.text._ZNSt6vectorI16domaincontrollerSaIS0_EED2Ev+0x0): error: undefined reference to '__gxx_personality_v0'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_begin_catch'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:426: error: undefined reference to '__cxa_rethrow'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_end_catch'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_end_cleanup'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ext/new_allocator.h:124: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.o(.ARM.extab.text._ZNSt6vectorI16domaincontrollerSaIS0_EE19_M_emplace_back_auxIIRKS0_EEEvDpOT_+0x0): error: undefined reference to '__gxx_personality_v0'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2208: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned int, unsigned int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:583: error: undefined reference to 'std::string::swap(std::string&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2208: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned int, unsigned int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:583: error: undefined reference to 'std::string::swap(std::string&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:97: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
msntauth.cc:98: error: undefined reference to 'std::string::find(char, unsigned int) const'
msntauth.cc:99: error: undefined reference to 'std::string::find(char, unsigned int) const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2758: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
msntauth.cc:107: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
msntauth.cc:108: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:113: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:324: error: undefined reference to 'std::__throw_out_of_range(char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to '__cxa_end_cleanup'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::__throw_bad_cast()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
msntauth.cc:115: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:113: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::cerr'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
msntauth.cc:61: error: undefined reference to 'std::ios_base::Init::~Init()'
msntauth.o(.ARM.extab.text.startup+0x0): error: undefined reference to '__gxx_personality_v0'
collect2: error: ld returned 1 exit status
make[3]: *** [basic_smb_lm_auth] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
更新: 将我的 ndk 更新为 android-ndk-r13b
并且错误仍然存在
您应该尝试使用 standalone toolchain。它们专门用于将 NDK 与非 NDK 构建系统一起使用。他们会搞清楚如何为你传递你需要的所有标志;你只需要调用 clang++
.
您可能还应该更新您的 NDK。 r10 现在已经三岁了。直到最近(r12,但您也可以升级到 r13),独立工具链才运行得很好。
我正在尝试为 android 构建 squid-3.5.24。我正在使用 android-ndk-r10e
进行构建。
这是我的环境。基于此:https://gist.github.com/nddrylliog/4688209
#!/bin/sh
# I put all my dev stuff in here
export DEV_PREFIX=$HOME/Documents
# Don't forget to adjust this to your NDK path
export ANDROID_NDK=$HOME/Android/android-ndk-r10e
export CROSS_COMPILE=arm-linux-androideabi
# I chose the gcc-4.7 toolchain - works fine for me!
export ANDROID_PREFIX=$DEV_PREFIX/toolchain/arm-linux-androideabi-4.8
# Apparently android-8 works fine, there are other versions, look them up
export SYSROOT=${ANDROID_PREFIX}/sysroot
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}
# Non-exhaustive lists of compiler + binutils
# Depending on what you compile, you might need more binutils than that
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib
export PATH=$PATH:$ANDROID_PREFIX/bin
export PATH=$PATH:${SYSROOT}/usr/lib
# This is just an empty directory where I want the built objects to be installed
export PREFIX=${SYSROOT}
# Don't mix up .pc files from your host and build target
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
# You can clone the full Android sources to get bionic if you want.. I didn't
# want to so I just got linker.h from here: http://gitorious.org/0xdroid/bionic
# Note that this was only required to build boehm-gc with dynamic linking support.
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} --cache-file=squid.cache "$@"
configure
成功完成我 运行 make
。在编译过程中,我得到这个错误:
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
collect2: error: ld returned 1 exit status
make[3]: *** [basic_smb_lm_auth] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
我认为该错误与链接器无法定位 libstdc++
或 libstdc++--v3
有关,但这些库存在于 sysroot/usr/lib
中,已提供给 ld
.
我曾尝试将库直接与 -lstdc++--v3
和 -lstdc++
链接,但这似乎与配置中的 gcc
混淆。
目前我无能为力,任何人都可以指出正确的方向吗?
这是 make
的其余输出:
Making all in compat
make[1]: Nothing to be done for `all'.
Making all in lib
Making all in snmplib
make[2]: Nothing to be done for `all'.
Making all in rfcnb
make[2]: Nothing to be done for `all'.
Making all in smblib
make[2]: Nothing to be done for `all'.
Making all in ntlmauth
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
Making all in libltdl
/Library/Developer/CommandLineTools/usr/bin/make all-am
make[2]: Nothing to be done for `all-am'.
Making all in scripts
make[1]: Nothing to be done for `all'.
Making all in icons
make[1]: Nothing to be done for `all'.
Making all in errors
make[1]: Nothing to be done for `all'.
Making all in doc
Making all in manuals
make[2]: Nothing to be done for `all'.
Making all in release-notes
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
Making all in helpers
Making all in basic_auth
Making all in DB
make[3]: Nothing to be done for `all'.
Making all in MSNT-multi-domain
make[3]: Nothing to be done for `all'.
Making all in NCSA
make[3]: Nothing to be done for `all'.
Making all in POP3
make[3]: Nothing to be done for `all'.
Making all in RADIUS
make[3]: Nothing to be done for `all'.
Making all in SMB
make[3]: Nothing to be done for `all'.
Making all in SMB_LM
/bin/sh ../../../libtool --tag=CXX --mode=link /Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-g++ -g -O2 -std=c++11 -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/sysroot/usr/lib -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/lib -o basic_smb_lm_auth msntauth.o valid.o ../../../lib/smblib/libsmblib.la ../../../lib/rfcnb/librfcnb.la ../../../lib/libmiscencoding.la ../../../compat/libcompat-squid.la -lm
libtool: link: /Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-g++ -g -O2 -std=c++11 -o basic_smb_lm_auth msntauth.o valid.o -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/sysroot/usr/lib -L/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/lib ../../../lib/smblib/.libs/libsmblib.a ../../../lib/rfcnb/.libs/librfcnb.a ../../../lib/.libs/libmiscencoding.a ../../../compat/.libs/libcompat-squid.a -lm
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:565: error: undefined reference to 'std::ostream::put(char)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:587: error: undefined reference to 'std::ostream::flush()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::__throw_bad_cast()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::cerr'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:152: error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.o(.ARM.extab.text._ZNSt6vectorI16domaincontrollerSaIS0_EED2Ev+0x0): error: undefined reference to '__gxx_personality_v0'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:249: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_begin_catch'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:426: error: undefined reference to '__cxa_rethrow'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_end_catch'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/vector.tcc:419: error: undefined reference to '__cxa_end_cleanup'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ext/new_allocator.h:124: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
msntauth.o(.ARM.extab.text._ZNSt6vectorI16domaincontrollerSaIS0_EE19_M_emplace_back_auxIIRKS0_EEEvDpOT_+0x0): error: undefined reference to '__gxx_personality_v0'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2208: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned int, unsigned int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:583: error: undefined reference to 'std::string::swap(std::string&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2208: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned int, unsigned int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:583: error: undefined reference to 'std::string::swap(std::string&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:56: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
msntauth.cc:97: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
msntauth.cc:98: error: undefined reference to 'std::string::find(char, unsigned int) const'
msntauth.cc:99: error: undefined reference to 'std::string::find(char, unsigned int) const'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:535: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:2758: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/locale_facets.h:869: error: undefined reference to 'std::ctype<char>::_M_widen_init() const'
msntauth.cc:107: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
msntauth.cc:108: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:113: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:324: error: undefined reference to 'std::__throw_out_of_range(char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to '__cxa_end_cleanup'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_ios.h:49: error: undefined reference to 'std::__throw_bad_cast()'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator<char> const&)'
msntauth.cc:115: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/ostream:113: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/bits/basic_string.h:539: error: undefined reference to 'std::cerr'
/Users/ozojiegerald/Documents/toolchain/arm-linux-androideabi-4.8/include/c++/4.8/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
msntauth.cc:61: error: undefined reference to 'std::ios_base::Init::~Init()'
msntauth.o(.ARM.extab.text.startup+0x0): error: undefined reference to '__gxx_personality_v0'
collect2: error: ld returned 1 exit status
make[3]: *** [basic_smb_lm_auth] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
更新: 将我的 ndk 更新为 android-ndk-r13b
并且错误仍然存在
您应该尝试使用 standalone toolchain。它们专门用于将 NDK 与非 NDK 构建系统一起使用。他们会搞清楚如何为你传递你需要的所有标志;你只需要调用 clang++
.
您可能还应该更新您的 NDK。 r10 现在已经三岁了。直到最近(r12,但您也可以升级到 r13),独立工具链才运行得很好。