2017-02-26 37 views
1

我想爲Android構建魷魚-3.5.24。我正在使用android-ndk-r10e進行構建。 這是我的環境。基於關閉此:https://gist.github.com/nddrylliog/4688209未定義的引用錯誤,當使用獨立的工具鏈來構建魷魚爲Android

#!/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 "[email protected]" 

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連接的事,但這些庫中已經提供給ldsysroot/usr/lib存在。

我試過直接鏈接庫-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 

UPDATE:更新了我的NDK到android-ndk-r13b和錯誤堅持

回答

1

你應該嘗試使用standalone toolchain。它們專門用於使用非NDK構建系統的NDK。他們會完成確定如何通過所有你需要的旗幟的工作;你只需要調用clang++

你也應該更新你的NDK。現在r10已經三歲了。直到最近,獨立工具鏈才能正常工作(r12,不過你可以升級到r13)。

+0

感謝您的回覆。我將'ndk'更新爲'android-ndk-r13b',但仍然出現同樣的錯誤 – lordzouga

+0

對不起,我誤解了你的問題。以爲你已經在使用獨立的工具鏈,而不是試圖自己構建一個工具鏈。我已經擴展了我的答案以包含其他信息。 –

+0

原來問題是,在我更新了我的'ndk'並創建了另一個工具鏈之後,我需要將'-lgnustl_shared'添加到鏈接器標誌中。這解決了這個特殊的問題。另一個關於函數沒有被聲明的錯誤,但這完全是另一個問題。感謝您的幫助。 – lordzouga

相關問題