牛骨文教育服务平台(让学习变的简单)
博文笔记

Windows下编译Ruby源代码

创建时间:2016-10-12 投稿人: 浏览次数:1385

为了在Windows下粘合Ruby扩展到应用程序,需要重新编译Ruby源代码,以便使用Visual Studio进行扩展的开发。使用第三方一键安装的版本开发工具使用的是Mingw下的GCC,无法满足需要。


源代码使用官网提供的源码包,直接从源代码库下载的源码需要额外的工具,代码包中有相关说明。


由于是用VS进行编译,缺省的Native包中gdbm和readline无法找到VS能编译的包,所以弃用。前者自己没用到,后者IRB会使用,缺少readline支持的IRB是比较蛋疼的。


把编译过程的命令行贴上,其中包括了自己常用的扩展,用以备忘


#openssl
cd E:ProjectsBuildRuby231externalopenssl-1.0.2
set PATH=d:
asm-2.12.02win32;%PATH%
d:Strawberryperlinperl.exe Configure VC-WIN32 enable-static-engine --prefix=D:Ruby23-x86srcexternal
msdo_nasm.bat
nmake -f ms
tdll.mak
nmake -f ms
tdll.mak install

#qdbm edit vcpath
cd E:ProjectsBuildRuby231externalqdbm-1.8.78
nmake -f VCmakefile

#tcl
cd E:ProjectsBuildRuby231external	cl8.5.19win
nmake -f makefile.vc
nmake -f makefile.vc install-libraries INSTALLDIR=D:Ruby23-x86srcexternal
nmake -f makefile.vc install-binaries INSTALLDIR=D:Ruby23-x86srcexternal

#tk
cd E:ProjectsBuildRuby231external	k8.5.19win
nmake -f makefile.vc TCLDIR=D:Ruby23-x86srcexternal
nmake -f makefile.vc TCLDIR=E:ProjectsBuildRuby231external	cl8.5.19
nmake -f makefile.vc install-libraries INSTALLDIR=D:Ruby23-x86srcexternal
nmake -f makefile.vc install-binaries INSTALLDIR=D:Ruby23-x86srcexternal

#zlib
cd E:ProjectsBuildRuby231externalzlib-1.2.8
nmake -f win32/Makefile.msc

#config ruby source
set INCLUDE=D:Ruby23-x86srcexternalinclude;D:Ruby23-x86srcexternalincludelibxml2;E:ProjectsBuildRuby231externalqdbm-1.8.78;E:ProjectsBuildRuby231externalzlib-1.2.8;%INCLUDE%
set LIB=D:Ruby23-x86srcexternallib;E:ProjectsBuildRuby231externalqdbm-1.8.78;E:ProjectsBuildRuby231externalzlib-1.2.8;%LIB%
cd E:ProjectsBuildRuby231
d:Ruby23-x86srcwin32configure.bat --prefix=/Ruby23-x86 --disable-install-doc
nmake
##退出再进入,有bug,路径会乱
cd E:ProjectsBuildRuby231
set PATH=D:Ruby23-x86srcexternalin;%PATH%
nmake install DESTDIR=D:

#libiconv msvc-2008
cd E:ProjectsBuildRuby231externallibiconv-1.11.1
nmake -f Makefile.msvc  DLL=1  MFLAGS=-MT  NO_NLS=1  PREFIX=D:Ruby23-x86srcexternal
nmake -f Makefile.msvc install  DLL=1  MFLAGS=-MT  NO_NLS=1  PREFIX=D:Ruby23-x86srcexternal

#libxml2
cd E:ProjectsBuildRuby231externallibxml2-2.9.4win32
cscript configure.js prefix=D:Ruby23-x86srcexternal include=D:Ruby23-x86srcexternalinclude;D:Ruby23-x86srcexternalincludelibxml2 lib=D:Ruby23-x86srcexternallib
nmake /f Makefile.msvc clean
nmake /f Makefile.msvc
nmake /f Makefile.msvc install

#libxslt
cd E:ProjectsBuildRuby231externallibxslt-1.1.29win32
cscript configure.js prefix=D:Ruby23-x86srcexternal include=D:Ruby23-x86srcexternalinclude;D:Ruby23-x86srcexternalincludelibxml2 lib=D:Ruby23-x86srcexternallib
nmake /f Makefile.msvc clean
nmake /f Makefile.msvc
nmake /f Makefile.msvc install

#nokogiri
set PATH=D:Ruby23-x86srcexternalin;D:Ruby23-x86srcexternallib;%PATH%
cd d:Ruby23-x86in
d:
gem update --system
gem install nokogiri -- --use-system-libraries --with-opt-include=D:Ruby23-x86srcexternalinclude;D:Ruby23-x86srcexternalincludelibxml2 --with-opt-lib=D:Ruby23-x86srcexternallib

#sqlite3
cd E:ProjectsBuildRuby231externalsqlite-dll-win32-x86-3140100
e:
lib /def:sqlite3.def /out:sqlite3.lib /machine:x86
cd d:Ruby23-x86in
d:
gem install sqlite3 -- --with-opt-include=E:ProjectsBuildRuby231externalsqlite-autoconf-3140100 --with-opt-lib=E:ProjectsBuildRuby231externalsqlite-dll-win32-x86-3140100

#oracle dbi
cd d:Ruby23-x86in
d:
gem install dbi
set ORACLE_HOME=D:oracleinstantclient-nt-12.1.0.2.0
set PATH=D:oracleinstantclient-nt-12.1.0.2.0;%PATH%
gem install ruby-oci8 -- --with-opt-include=D:oracleinstantclient-nt-12.1.0.2.0sdkinclude --with-opt-lib=D:oracleinstantclient-nt-12.1.0.2.0sdklibmsvc

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。