编译的时候报各种错误,在网上查找了很多资料,做下总结,希望能帮助到和我一样的初学者
我的系统环境:CentOS6.5 Oracle VirtualBox4.3
建议磁盘空间大于10G
需要的软件:
jdk7 或者更高
maven-3.0.5或者更高
findbugs3.0.0
protobuf2.5.0
cmake2.6 或更高
openssl-devel
可以使用:rpm -qa | grep cmake 查看版本,来验证是否安装
1、安装jdk7,如果编译出问题可以换其他版本尝试
rpm -ivh jdk-7-linux-x64.rpm
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0
export PATH=$JAVA_HOME/bin:
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
用jdk1.8编译的时候会出现很多错误,慎用
2、安装maven最新版本
tar -zxvf apache-maven-3.0.5-bin.tar.gz
vim /etc/peofile
export MAVEN_HOME=/usr/local/apache-maven-3.0.5
export PATH=$PATH:$MAVEN_HOME/bin
因为国外服务器连接有问题,需要从开源中国上下载
如果按默认maven配置,在编译的时候可能报findbugs.xml找不到的错误
所以修改配置文件conf/settings.xml,如下:
<mirror>
<id>mexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexusosc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
<profile>
<id>jdk-1.7</id>
<activation>
<jdk>1.7</jdk>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
3、安装findbugs3.0.0
tar zxvf findbugs-3.0.0.tar.gz
vim /etc/profile
export FINDBUGS_HOME=/usr/local/findbugs-3.0.0
export PATH=$PATH:$FINDBUGS_HOME/bin
4、安装protobuf2.5.0
tar zxvf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure --prefix=/usr/local
make && make install
5、安装Ant
tar zxvf apache-ant-1.9.4-bin.tar.gz
vim /etc/profile
export ANT_HOME=/usr/local/apache-ant-1.9.4
export PATH=$PATH:$ANT_HOME/bin
6、安装cmake
yum install cmake
7、安装openssl-devel
yum install openssl-devel
错误1:error: no acceptable C compiler found in $PATH
解决方法:
# yum -y install gcc
安装更新了如下几个组件:
gcc 4.1.2-44.el5
binutils 2.17.50.0.6-9.el5
cpp 4.1.2-44.el5
glibc-devel 2.5-34.el5_3.1
glibc-headers 2.5-34.el5_3.1
kernel-headers 2.6.18-164.el5
libgomp 4.3.2-7.el5
错误2:error: C++ preprocessor "/lib/cpp" fails sanity check.
解决方法:
yum install glibc-headers
yum install gcc-c++
错误3:磁盘空间不足
解决方法:www.2cto.com/os/201210/159318.html
以上软件全部安装好以后基本上不会出现什么问题
就可以到hadoop源码文件夹下进行编译
mvn package -Pdist,native,docs,src -DskipTests -Dtar
半个小时后,在hadoop-dist/target/下看编译好的jar