最近想看看大数据方面的东西,但是win下开发需要winutils.exe和hadoop.dll否则总是报错,虽然能运行但是看着烦,所以决定自己编译下native
一、环境搭建
1.我用到的软件等
注意下版本信息,jdk1.7 vs2010 等,否则会出问题
二、软件的安装
仔细阅读hadoop-2.7.6-src下的BUILDING.txt
---------------------------------------------------------------------------------- Building on Windows ---------------------------------------------------------------------------------- Requirements: * Windows System * JDK 1.7+ * Maven 3.0 or later * Findbugs 1.3.9 (if running findbugs) * ProtocolBuffer 2.5.0 * CMake 2.6 or newer * Windows SDK 7.1 or Visual Studio 2010 Professional * Windows SDK 8.1 (if building CPU rate control for the container executor) * zlib headers (if building native code bindings for zlib) * Internet connection for first build (to fetch all Maven and Hadoop dependencies) * Unix command-line tools from GnuWin32: sh, mkdir, rm, cp, tar, gzip. These tools must be present on your PATH. Unix command-line tools are also included with the Windows Git package which can be downloaded from http://git-scm.com/download/win. If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012). Do not use Visual Studio Express. It does not support compiling for 64-bit, which is problematic if running a 64-bit system. The Windows SDK 7.1 is free to download here: http://www.microsoft.com/en-us/download/details.aspx?id=8279 The Windows SDK 8.1 is available to download at: http://msdn.microsoft.com/en-us/windows/bg162891.aspx Cygwin is neither required nor supported.
这里我只截取了一段。这里有比较详细的说明。
1.vs2010自己去百度安装了
2.maven与ant的安装配置自己百度了。
3.findbugs-1.3.9.zip 解压后配置环境变量 FINDBUGS_HOME E:\worksoft\findbugs-1.3.9
4.cmake-3.11.1-win64-x64.zip 解压后配置path 添加
;E:\worksoft\cmake-3.11.1-win64-x64\bin
5.protoc-2.5.0-win32.zip 这个解压后protoc.exe 直接放到C:\Windows\System32面
6.Git-2.16.2-64-bit.zip 解压后安装,注意unix相关命令的选项都选上,因为要用到unix的命令
7.zlib128-dll.zip解压后配置环境变量,path添加
;C:\zlib128-dll
此处注意include文件夹中的两个.h文件复制到根目录,否则有可能找不到而编译报错,这个在console里面还看不到,我是直接编译common才看到的错误信息。
8.Win32OpenSSL-1_0_2o.zip这个解压后安装,我使用的32位的,64位的貌似抱错了,安装完成配置环境变量,path添加
;C:\OpenSSL-Win32\bin
9.winsdk_web7.1.zip 解压后安装,8.1的我没用上。
10.配置环境变量Platform=x64 这个注意大小写敏感
三、编译
我是使用vs2010的命令窗口启动的git的cmd窗口,因为会报msbuild找不到。
切换到源码根目录
编译命令 mvn package -Pdist,native-win -DskipTests -Dtar
然后就是漫长的等待
编译好的文件在 F:\hadoop-2.7.6-src\hadoop-dist\target\hadoop-2.7.6
四、问题
虽然之前已经编译过一次了,但是还是出了点问题。
有问题多用下 mvn -e -X 。。。能看到更详细的信息。
LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 解决办法
找到这三个目录,找到cvtres.exe
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin C:\Windows\winsxs\x86_netfx-cvtres_for_vc_and_vb_b03f5f7f11d50a3a_6.1.7600.16385_none_ba476986f05abc65 C:\Windows\Microsoft.NET\Framework\v4.0.30319
比较这三个文件夹里cvtres.exe的版本,把版本大的复制到vs安装目录里
2.maven 的库我配置的阿里云的,这个比较全
<mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
彩蛋:当然了这里编译完成后,win下开发eclipse还需要插件,有时间写下插件的编译
乐享:知识积累,快乐无限。