解决Android 源码编译“audio_processing_impl”时,报错“fatal error: list: No such file or directory”问题

我的系统是Linux Mint 17,使用的平台是Tiny4412,编译的是友善之臂提供的Android 4.2.2 源码。之前编译没有问题,今天编译时,报出这个错误,查遍 百度/Google 都没解决,后来发现是我之前手贱多配置了一个环境变量 NDK_ROOT 导致的问题,报错如下:

target arm C++: libwebrtc_apm <= external/webrtc/src/modules/audio_processing/audio_processing_impl.cc
In file included from external/webrtc/src/modules/audio_processing/audio_processing_impl.cc:11:0:
external/webrtc/src/modules/audio_processing/audio_processing_impl.h:16:16: fatal error: list: No such file or directory
compilation terminated.
make: *** [out/target/product/tiny4412/obj/STATIC_LIBRARIES/libwebrtc_apm_intermediates/audio_processing_impl.o] Error 1

分析过程如下:

查的两个地址:

http://grokbase.com/t/gg/android-building/1336gfcert/building-android-4-2-1-problems-with-stl-reference-in-source-tree

http://bbs.csdn.net/topics/390143470

看后无果,只知道是没找到头文件“list”,在工程目录下使用

find ./ -name "list"
找到了包括“./external/stlport/stlport/list”等多个文件,说明文件是有的,就是没链接上。


于是,跑去

external/webrtc/src/modules/audio_processing/Android.mk
看看是怎么回事,Android.mk内容如下(省略部分无关信息):

#省略。。。
LOCAL_SRC_FILES := \
    $(call all-proto-files-under, .) \
    audio_buffer.cc \
    audio_processing_impl.cc \
    echo_cancellation_impl.cc \
    echo_control_mobile_impl.cc \
    gain_control_impl.cc \
    high_pass_filter_impl.cc \
    level_estimator_impl.cc \
    noise_suppression_impl.cc \
    splitting_filter.cc \
    processing_component.cc \
    voice_detection_impl.cc
#省略。。。
ifndef NDK_ROOT
include external/stlport/libstlport.mk
endif
#省略。。。
ifdef NDK_ROOT
include $(BUILD_EXECUTABLE)
else
include external/stlport/libstlport.mk
include $(BUILD_NATIVE_TEST)
endif
#省略。。。
ifdef NDK_ROOT
include $(BUILD_EXECUTABLE)
else
include external/stlport/libstlport.mk
include $(BUILD_NATIVE_TEST)
endif

猛然发现,这里有多处
ifdef NDK_ROOT
且看最后一个ifdef中

ifdef NDK_ROOT
include $(BUILD_EXECUTABLE)
else
include external/stlport/libstlport.mk
include $(BUILD_NATIVE_TEST)
endif

如果没有定义

NDK_ROOT
则会包含
external/stlport/libstlport.mk
慢着!怎么这么眼熟,stlport?这不是刚刚搜索结果中的一个吗?马上查看libstlport.mk,看看里面都是什么?

# Add a couple include paths to use stlport.

# Make sure bionic is first so we can include system headers.
LOCAL_C_INCLUDES := \
	bionic \
	external/stlport/stlport \
	$(LOCAL_C_INCLUDES)

“external/stlport/stlport”!!!还有“bionic”!!!这两条都在前面提到的地址中提到

http://grokbase.com/t/gg/android-building/1336gfcert/building-android-4-2-1-problems-with-stl-reference-in-source-tree

原文如下:

I posted this same question into the forum earlier, but it has not
appeared. Apologies if this does end up appearing twice.

When building Android 4.2.1 I'm getting the following error...

target arm C++: libwebrtc_apm <=
external/webrtc/src/modules/audio_processing/audio_processing_impl.cc
In file included from
external/webrtc/src/modules/audio_processing/audio_processing_impl.cc:11:0:
external/webrtc/src/modules/audio_processing/audio_processing_impl.h:16:16:
fatal error: list: No such file or directory
compilation terminated.

This is referring to the following line in audio_processing_impl.cc...

#include 


In other words, it appears to not know about STL.

I ran the build using the same source tree on a colleague's PC (which
builds without error), and compared the builds when using showcommands. On
my colleague's PC there was one difference in the build command for
audio_processing_impl.cc - the inclusion in his case of the following...

-I bionic -I external/stlport/stlport -I


... Which explains why this is going wrong. Without this line, on my PC
the build does not have the necessary STL references.

I've looked at the various packages installed on both machines, and they
appear the same - and in any case, I was under the impression the toolchain
was integrated in the Android source tree,

One other difference which may well be the cause of the problem is that my
PC runs Ubuntu 12.10, whilst my colleague's PC is running 12.04. I'm know
that 12.10 may cause issues - and this may be one of them - but does the
above ring any bells with anyone out there? What could cause the Android
build to omit that reference to the STL code?

Any help much appreciated!
Tim

也就是说,我并没有包含到 libstlport.mk ,进而说明,我定义了NDK_ROOT,后来一查:

$ echo $NDK_ROOT
/opt/android-ndk-r10
果然如此!所以,我临时解除了NDK_ROOT变量

$ unset NDK_ROOT
然后,

make
就通过了!!!

真是手贱害死人啊~
只要这一轮正常编译,不使用make clean清空就不需要管NDK_ROOT环境变量了,你重设也好,重启系统也罢,下次遇到这个问题,若你定义了NDK_ROOT,unset一下试试吧。


参考文献:

1. http://grokbase.com/t/gg/android-building/1336gfcert/building-android-4-2-1-problems-with-stl-reference-in-source-tree     [android-building] Building Android 4.2.1... problems with STL reference in source tree

2. http://bbs.csdn.net/topics/390143470     编译Android源码出错!!!

3. http://zhidao.baidu.com/link?url=lZhd8cm9cR05WwCCu22Vgkq_W2K91gefD0ncet5xp-8tHNKic1Ls-UhgjdmDINmATkFjJdneVYv4pr4aDtsMQ_   百度知道-原生的Android代码上创建自己的product,编译出错!!!

4. http://qnalist.com/questions/5099386/android-building-android-4-2-1-build-problems-c-stl-issue-with-external-webrtc-src-modules-audi       [android-building] Android 4.2.1 Build Problems: C++ STL Issue With External/webrtc/src/modules/audi



你可能感兴趣的:(Android,源码)