前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android So编译错误

Android So编译错误

作者头像
艳龙
发布2021-12-16 17:26:37
1.5K0
发布2021-12-16 17:26:37
举报
文章被收录于专栏:yanlongli_艳龙

今天和往常一样调用脚本编译so,突然提示如下错误:

代码语言:javascript
复制
../../base/allocator/allocator_extension.h:17:45: error: unknown type name 'size_t'
using AllocHookFunc = void (*)(const void*, size_t);
                                            ^
../../base/allocator/allocator_extension.h:28:55: error: unknown type name 'size_t'
BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
                                                      ^
In file included from ../../base/allocator/allocator_extension.cc:7:
In file included from ../../base/logging.h:11:
In file included from ../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:61:
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:74:64: error: use of undeclared identifier 'strchr'
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
                                                               ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:81:75: error: use of undeclared identifier 'strpbrk'
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
                                                                          ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:88:65: error: use of undeclared identifier 'strrchr'; did you mean 'strchr'?
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
                                                                ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:76:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
            ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:95:49: error: unknown type name 'size_t'
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
                                                ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:97:46: error: unknown type name 'size_t'
const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
                                             ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:99:46: error: unknown type name 'size_t'
      void* memchr(      void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
                                             ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:102:74: error: use of undeclared identifier 'strstr'; did you mean 'strchr'?
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                         ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:78:13: note: 'strchr' declared here
      char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
            ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:102:74: error: no matching function for call to 'strchr'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                         ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:78:13: note: candidate disabled: <no message provided>
      char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
            ^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:102:81: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
                                                                                ^~~~
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:78:32: note: passing argument to parameter '__s' here
      char* strchr(      char* __s, int __c) {return __libcpp_strchr(__s, __c);}
                               ^
In file included from ../../base/allocator/allocator_extension.cc:7:
In file included from ../../base/logging.h:11:
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:69:9: error: no member named 'size_t' in the global namespace
using ::size_t;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:70:9: error: no member named 'memcpy' in the global namespace; did you mean 'memchr'?
using ::memcpy;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:99:13: note: 'memchr' declared here
      void* memchr(      void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
            ^
In file included from ../../base/allocator/allocator_extension.cc:7:
In file included from ../../base/logging.h:11:
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:71:9: error: no member named 'memmove' in the global namespace
using ::memmove;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:72:9: error: no member named 'strcpy' in the global namespace; did you mean 'strchr'?
using ::strcpy;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:76:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
            ^
In file included from ../../base/allocator/allocator_extension.cc:7:
In file included from ../../base/logging.h:11:
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:73:9: error: no member named 'strncpy' in the global namespace
using ::strncpy;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:74:9: error: no member named 'strcat' in the global namespace; did you mean 'strchr'?
using ::strcat;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:76:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
            ^
In file included from ../../base/allocator/allocator_extension.cc:7:
In file included from ../../base/logging.h:11:
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:75:9: error: no member named 'strncat' in the global namespace
using ::strncat;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/cstring:76:9: error: no member named 'memcmp' in the global namespace; did you mean 'memchr'?
using ::memcmp;
      ~~^
../../../../../../../tool/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/string.h:99:13: note: 'memchr' declared here
      void* memchr(      void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

看到这些错误一脸懵逼,size_t 不是基础类型吗,怎么会找不到。 google 一番没有任何结果,可以明确知到不是代码逻辑问题,是依赖的环境变量问题,具体的是哪个环境引起的错误,一头雾水。

经过一番测试后找到了问题原因: xcode 版本升级为11.0 后, gcc 依赖的编译环境发生变化,导致编译错误。 解决方案: 安装一个xcode 10.2版本,重新编译后,问题消失 tip:中间替换了ndk,sdk等版本来确定是否因为这些问题导致

mac 中同时安装不同版本的xcode,可以使用如下命令切换主xcode

代码语言:javascript
复制
$ sudo xcode-select -switch /Applications/Xcode.app(xcode保存的位置)
Password:// 输入密码后就可以修改成功
$ xcodebuild -version 
Xcode 10.2.1
Build version 10E1001
$ xcode-select -p  
/Users/Documents/tool/Xcode.app/Contents/Developer
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/12/23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档