第五步_安装编译必须的软件包依赖包

上一步:第四步_安装gcc交叉编译工具
在编译Android SDK代码的时候,需要安装一些必要的软件包和依赖包,否则会出现一些奇奇怪怪的报错,如果你懒得等到碰到报错的时候再去解决,可以直接在命令行界面执行以下的【解决方法】的语句,安装对应的软件包或者依赖包即可。

1、sudo apt-get install vim (安装完整版本的 VI) ,这个工具在编辑代码源文件的时候会使用到,建议安装一下。

2、安装工具链
执行以下命令:

$ sudo apt-get install cvs build-essential automake autoconf libtool bison flex
$ sudo apt-get install libncurses5-dev  

3、添加库函数手册
ubuntu 默认是没有安装c 语言的库函数man手册的,所以你在man perror 和sendto 之类的函数时会显示没有相关文档的问题,这个问题的解决方法是:

$ sudo apt-get install binutils-doccpp-doc gcc-4.4-doc gcc-doc glibc-doclibstdc++6-4.4-docstl-manual cpp-4.4-doc manpages manpages-dev  

4、xxx is not in the sudoers file.This incident will be reported.的解决方法
1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去.
2.添加sudo文件的写权限,命令是: chmod u+w /etc/sudoers
3.编辑sudoers文件
vi /etc/sudoers

找到这行root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL(这里的xxx是你的用户名)

ps:这里说下你可以sudoers添加下面四行中任意一条
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL
第一行:允许用户youuser执行sudo命令(需要输入密码).
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.
4.撤销sudoers文件写权限,
命令: chmod u-w /etc/sudoers
这样普通用户就可以使用sudo了.

5、Linux kernel make menuconfig 时出错处理方法
由于缺少必要的package,所以出现了编译问题:
在这里插入图片描述
解决方法:sudo apt-get install build-essential libncurses5 libncurses5-dev

/###########################/
android下的环境的搭建常见的错误
/###########################/

其实正确的做法是把下面的解决方法都执行一遍,就不用去看具体的报错了。

1、出现下面的编译报错:/bin/bash:xmllint:command not found make:***[out/target/product/pandaboard/system/etc/system_fonts.xml] Error 127 make:*** Waiting for unfinished jobs…

解决方法:sudo apt-get install libxml2-utils

2、/bin/bash: bison: command not found
解决方法:sudo apt-get install bison

3、/bin/bash: xsltproc: command not found
解决方法:sudo apt-get install xsltproc

4、/bin/bash: flex: command not found make:***[out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127

解决方法:sudo apt-get install flex

sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
解决方法:sudo apt-get install gperf

gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
解决方法:sudo apt-get install g++

首先,我们先安装一些常用的工具【依次执行以下安装语句:sudo XXXX】:

安装curl: sudo apt-get install curl
安装git: sudo apt-get install git
安装g++: sudo apt-get install g++

/usr/bin/ld: cannot find -lz Host executable aapt(out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1

解决方法: sudo apt-get install zlib1g-dev sudo apt-get install lib64z1-dev(版本已改变)

/bin/bash: bison: command not found Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y Bison-d-o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y /bin/bash: bison: command not found make:***[out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127

解决方法:sudo apt-get install bison

/bin/bash: flex: command not found out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function ‘int yyparse()’: out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827: warning: deprecated conversion from string constant to ‘char*’ out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970: warning: deprecated conversion from string constant to ‘char*’ Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l /bin/bash: flex: command not found make:***[out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127

解决方法: sudo apt-get install flex

/usr/bin/ld: cannot find -lncurses host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb) /usr/bin/ld: cannot find -lncurses collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1

解决方法:sudo apt-get install libncurses5-dev

fatal error: GL/glx.h: No such file or directory development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory compilation terminated. make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1

解决方法:sudo apt-get install libgl1-mesa-dev

sh: gperf: not found target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables Generating CSSPropertyNames.h <= CSSPropertyNames.in sh: gperf: not found calling gperf failed: 32512 at ./makeprop.pl line 140. make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h’

解决方法
执行:sudo apt-get install gperf
执行:sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 \ libgl1-mesa-dev g+±multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 libgl1-mesa-glx:i386
执行:sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

################################
以下是一些常见的环境搭建时的错误
################################
1、出现没有GCC或者G++没有添加,可以使用gcc进行编译文件,会有提示添加一些必要的文件。按照提示更新就可以。
解决方法:sudo apt-get install gcc sudo apt-get install build-essential

2、Unable to exec g++.real: No such file or file
解决方法: sudo apt-get install build-essential

3、当以root的权限执行sudo -exportfs-a 时出现 sudo: unable to resolve host waveshare
解决方法:只要去掉前面的sudo就可以了

4、"mkimage"command not found - U-Boot images will not be built make[1]😗**[arch/arm/boot/uImage] Error 1 make:***[uImage] Error 2 如果使用的是Ubuntu 9.10及以上版本,可以使用下面的命令安装mkimage:
解决方法:sudo apt-get install uboot-mkimage

5、/usr/bin/ld:cannot find -lxxx 问题总结 linux下编译应用程序常常会出现如下错误: /usr/bin/ld:cannot find -lxxx 意思是编译过程找不到对应库文件。其中,-lxxx表示链接库文件libxxx.so。 注:有时候,由于库文件是编译过程临时生成的,如果前面出错也会导致出现这种情况,下面针对的是由于本机系统环境缺失而引起的 。

一般出现这种错误有以下几种原因:
1.系统缺乏对应的库文件;
2.版本不对应;
3.库文件的链接错误;
4.库文件路径设置问题;

对应第一第二种情况,可以通过下载安装lib来解决,ubuntu大多数可以直接通过apt-get来安装:
解决方法:sudo apt-get install libxxx-dev

一般遇到这种问题笔者第一时间也是会去检查系统是否已安装该lib或者是否已选择正确版本(只是习惯问题),如果还是不能解决问题, 那么,引起错误的原因不是链接错误就是库文件路径问题了。 通过find或者locate指令定位到链接文件,查看链接文件是否正确的指向了我们希望的lib,如果不是,用ln -sf /libxxx.so.x/libxxx.so指令修改它。 如果是库文件路径引发的问题,可以到/etc/ld.so.conf.d目录下,修改其中任意一份conf文件,(可以自建conf,以方便识别)将lib所在 目录写进去,然后在终端输入ldconfig 更新缓存。

6、执行安装libncurses5
解决方法:sudo apt-get install libncurses5-dev

root@waveshare:/usr/lib# sudo apt-get install libncurses5-dev
Reading package lists… Done
Building dependencytree
Reading state information… Done
The following packages were automaticallyinstalled and are no longer required:
lib32ncurses5 liblzo2-2
Use ‘apt-get autoremove’ to remove them.
Suggested packages:
ncurses-doc
The following NEWpackages will be installed:
libncurses5-dev 0 upgraded, 1 newlyinstalled, 0 to remove and 20 not upgraded.
Need to get 0 B/222 kB of archives.
After this operation, 1,223 kB of additional disk space will be used.
Selecting previously unselected package libncurses5-dev.
(Reading database … 214172 files and directoriescurrentlyinstalled.)
Unpacking libncurses5-dev(from …/libncurses5-dev_5.9-4_amd64.deb) …
Setting up libncurses5-dev(5.9-4) …
root@waveshare:/usr/lib# apt-get autoremove lib32ncurses5
Reading package lists… Done
Building dependencytree
Reading state information… Done
The following packages will be REMOVED:
lib32ncurses5 liblzo2-2
0 upgraded, 0 newlyinstalled, 2 to remove and 20 not upgraded.
After this operation, 647 kB disk space will be freed.
Do you want to continue [Y/n]?y

8、执行make menuconfig的时候报如下错误: www.linuxidc.com @www.linuxidc.com:~/work/linux_3.9.5/linux-3.9.5$ make menuconfigHOSTLD scripts/kconfig/mconf scripts/kconfig/mconf.o: In function show_help': mconf.c:(.text+0x764): undefined reference tostdscr’ scripts/kconfig/lxdialog/checklist.o: In function print_arrows': checklist.c:(.text+0x41): undefined reference towmove’
checklist.c:(.text+0x61): undefined reference to acs_map' checklist.c:(.text+0x69): undefined reference towaddch’
checklist.c:(.text+0x7b): undefined reference to waddnstr' checklist.c:(.text+0x8c): undefined reference towmove’
checklist.c:(.text+0xb3): undefined reference to acs_map' checklist.c:(.text+0xbb): undefined reference towaddch’
checklist.c:(.text+0x10b): undefined reference to `acs_map’

解决方法:sudo apt-get install libncurses5 libncurses5-dev

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

零意@

您的打赏将是我继续创作的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值