您的位置:首页 > 移动开发 > Android开发

【转】Ubuntu 11.04 下 Android4.0.1 编译错误解决方法

2012-05-17 09:19 579 查看
1.错误一:error: ‘ptrdiff_t’ does not name a type

In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,

from external/gtest/src/../include/gtest/gtest.h:69,

from external/gtest/src/gtest_main.cc:32:

external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type

In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,

from external/gtest/src/../include/gtest/gtest.h:69,

from external/gtest/src/../src/gtest.cc:34,

from external/gtest/src/gtest-all.cc:36:

external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type

In file included from external/gtest/src/gtest-all.cc:38:0:

解决方法:

$vi external/gtest/src/../include/gtest/internal/gtest-param-util.h

#include <cstddef>

2.错误二:undefined reference to `pthread_mutexattr_destroy'

host C++: libgtest_host <= external/gtest/src/gtest-all.cc

true

host C++: libgtest_main_host <= external/gtest/src/gtest_main.cc

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o): In function `PrintStackTrace':

/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219: undefined reference to `dladdr'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:231: undefined reference to `dladdr'

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':

/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl':

/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'

/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':

/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1

make: *** Waiting for unfinished jobs....

解决方法:

$vi external/llvm/llvm-host-build.mk

LOCAL_LDLIBS := -lpthread -ldl

下面这个解决方法没成功,会有新的错误:errors again :can't find threads.h file or dir.

$ vi external/llvm/lib/Support/Android.mk

LOCAL_C_INCLUDES += system/core/include/cutils

LOCAL_SHARED_LIBRARIES := libcutil

$ vi external/llvm/lib/Support/Mutex.cpp

#include <threads.h>

$ vi external/llvm/lib/Support/Threading.cpp

#include <threads.h>

3.错误三:error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]

frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]

cc1plus: all warnings being treated as errors

解决方法:

$ vi frameworks/compile/slang/Android.mk

#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror

local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter

这些错误有GCC4.6的,也有Android4.0的,在ubuntu和Android的官网上都有记载,可参看:

http://code.google.com/p/android/issues/detail?id=22011

http://code.google.com/p/android/issues/detail?id=22006#c0

http://groups.google.com/group/android-building/browse_thread/thread/0207abb98ed72304
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: