部署 vc6 编译 ruby 源码出错了

sevk · 2014年07月11日 · 最后由 sevk 回复于 2014年07月14日 · 3301 次阅读



G:\ruby-2.1.2\win32>nmake

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

    CC = cl -nologo
    LD = cl -nologo
    LDSHARED = cl -nologo -LD
    CFLAGS = -MD -Zi -W2 -O2b2xg- -G6 -Zm600
    XCFLAGS = -DRUBY_EXPORT -I. -I.ext/include/i386-mswin32 -IG:/ruby-2.1.2/

include -IG:/ruby-2.1.2 -IG:/ruby-2.1.2/missing
CPPFLAGS =
DLDFLAGS = -incremental:no -debug -opt:ref -opt:icf -dll
SOLIBS =
Creating config.h
.ext\include\i386-mswin32\ruby\config.h updated
Creating config.status
compiling G:/ruby-2.1.2/main.c
main.c 

...

compiling file.c
file.c
compiling G:/ruby-2.1.2/gc.c
gc.c
G:/ruby-2.1.2/gc.c(4508) : warning C4244: '=' : conversion from 'double ' to 'un
signed int ', possible loss of data
G:/ruby-2.1.2/gc.c(4509) : warning C4244: '=' : conversion from 'double ' to 'un
signed int ', possible loss of data
compiling G:/ruby-2.1.2/hash.c
hash.c
...
compiling G:/ruby-2.1.2/dmyext.c
dmyext.c
oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib imagehlp.lib shlwapi
.lib
linking miniruby.exe
file.obj : error LNK2005: rb_file_expand_path_internal already defined in file.
obj
file.obj : error LNK2005: rb_file_load_ok already defined in file.obj
file.obj : error LNK2005: Init_w32_codepage already defined in file.obj
dir.obj : error LNK2001: unresolved external symbol rb_enc_path_skip_prefix
dir.obj : error LNK2001: unresolved external symbol _rb_str_encode_ospath
load.obj : error LNK2001: unresolved external symbol _rbstr_encode_ospath
io.obj : error LNK2001: unresolved external symbol _rb_str_encode_ospath
ruby.obj : error LNK2001: unresolved external symbol _rbstr_encode_ospath
dir.obj : error LNK2001: unresolved external symbol rb_file_const
dir.obj : error LNK2001: unresolved external symbol rb_cFile
io.obj : error LNK2001: unresolved external symbol _rbcFile
dir.obj : error LNK2001: unresolved external symbol _rbfile_directory_p
iseq.obj : error LNK2001: unresolved external symbol _rbget_path
dir.obj : error LNK2001: unresolved external symbol rb_get_path
load.obj : error LNK2001: unresolved external symbol rb_get_path
io.obj : error LNK2001: unresolved external symbol rb_get_path
process.obj : error LNK2001: unresolved external symbol _rbgetpath
dir.obj : error LNK2001: unresolved external symbol rb_enc_path_end
dir.obj : error LNK2001: unresolved external symbol _rbget_pathno_checksafe
dir.obj : error LNK2001: unresolved external symbol _rb_default_home_dir
dir.obj : error LNK2001: unresolved external symbol _rb_home_dir_of
dln_find.obj : error LNK2001: unresolved external symbol _eaccess
win32.obj : error LNK2001: unresolved external symbol _eaccess
eval.obj : error LNK2001: unresolved external symbol _rbfile_dirname
load.obj : error LNK2001: unresolved external symbol rb_file_dirname
load.obj : error LNK2001: unresolved external symbol rb_file_expand_path_fast
load.obj : error LNK2001: unresolved external symbol rb_get_path_check_convert
load.obj : error LNK2001: unresolved external symbol _rb_is_absolute_path
load.obj : error LNK2001: unresolved external symbol _rbget_path_check_to_strin
g
load.obj : error LNK2001: unresolved external symbol _rbfind_file
load.obj : error LNK2001: unresolved external symbol rb_realpath_internal
ruby.obj : error LNK2001: unresolved external symbol _rb_realpath_internal
iseq.obj : error LNK2001: unresolved external symbol _rbrealpath_internal
load.obj : error LNK2001: unresolved external symbol _rbfile_absolute_path
load.obj : error LNK2001: unresolved external symbol rb_find_file_ext_safe
load.obj : error LNK2001: unresolved external symbol rb_find_file_safe
gc.obj : error LNK2001: unresolved external symbol __aligned_malloc
gc.obj : error LNK2001: unresolved external symbol _aligned_free
hash.obj : error LNK2001: unresolved external symbol _rbpath_check
io.obj : error LNK2001: unresolved external symbol _Init_File
ruby.obj : error LNK2001: unresolved external symbol _rb_file_expand_path
miniruby.exe : fatal error LNK1120: 26 unresolved externals
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.


共收到 11 条回复

https://ruby-china.org/topics/18839 非常不建议用windows 开发ruby 环境。 马上楼下会有一波人劝你别用windows开发ruby

可选方案 1.起个虚拟机环境 安装ubuntu 12.04.在linux 环境下安装。 1.如果非要用windows .https://bitnami.com/stack/ruby 使用这个一键安装ruby 环境

https://bugs.ruby-lang.org/issues/7660

You can build ruby in any directory including the source directory, except win32 directory in the source directory.

看起来你在外面比如 G:\ruby-2.1.2 目录下运行 nmake 就可以了吧……

#3楼 @dorentus 多谢, 原来需要把README 看完才行,写在最后面的

#2楼 @wcc526 linux和虚拟机已经玩过了,一键安装也玩过了,没啥问题。所以现在玩玩 vc6

#5楼 @sevk 目的是,研究源代码?

#6楼 @wcc526 目的是玩玩 exerb-mingw , ocra 已经玩过了。 安装 exerb-mingw 没成功,我就想是不是需要自己编译 ruby 了。

#4楼 @sevk 其实我是现搜的,你那个日志里的第一个错 “error LNK2005: rb_file_expand_path_internal already defined in file”,Google 一下就两个结果,一个是那个 issue,一个是本帖。。。

#7楼 @sevk exerb-mingw可以用我 fork 的版本,只要有 DevKit 就可以编译。RUBY 本身不需要自己编译

#9楼 @windwiny 多谢,我试试。 原来你也在这里啊。太好了

#10楼 @sevk

试了一下,安装gem时报错了:


G:\dev-tools\exerb>gem build exerb.gemspec
  Successfully built RubyGem
  Name: exerb
  Version: 6.0.1
  File: exerb-6.0.1.gem

G:\dev-tools\exerb>gem install exerb-6.0.1.gem
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing exerb-6.0.1.gem:
        ERROR: Failed to build gem native extension.

        D:/Ruby193/bin/ruby.exe extconf.rb
mkdir -p tmp
windres -DCUI src/exerb/resource.rc tmp/resource_cui.o
mkdir -p tmp
mkdir -p data/exerb
gcc  -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno
-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-s
trings  -DRUBY_EXPORT -DRUBY19 -DRUBY19_COMPILED_CODE -DFD_SETSIZE=2048  -DFD_SE
TSIZE=2048 -ID:/Ruby193/include/ruby-1.9.1/i386-mingw32 -ID:/Ruby193/include/rub
y-1.9.1 -LD:/Ruby193/lib -Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb
_require     -s -o data/exerb/ruby193c.exc src/exerb/cui.c tmp/resource_cui.o sr
c/exerb/exerb.c src/exerb/module.c src/exerb/utility.c src/exerb/patch.c tmp/exe
rb53.def -lmsvcrt-ruby191-static -lshell32 -lws2_32 -limagehlp -lshlwapi
src/exerb/exerb.c:49:1: warning: missing braces around initializer
src/exerb/exerb.c:49:1: warning: (near initialization for 'g_loaded_library_tabl
e[0]')
src/exerb/exerb.c:50:1: warning: missing braces around initializer
src/exerb/exerb.c:50:1: warning: (near initialization for 'g_pre_loaded_library_
table[0]')
strip -R .reloc data/exerb/ruby193c.exc
mkdir -p tmp
windres -DRUNTIME src/exerb/resource.rc tmp/resource_dll.o
mkdir -p tmp
mkdir -p data/exerb
gcc  -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno
-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-s
trings  -DRUBY_EXPORT -DRUBY19 -DRUBY19_COMPILED_CODE -DFD_SETSIZE=2048  -DFD_SE
TSIZE=2048 -ID:/Ruby193/include/ruby-1.9.1/i386-mingw32 -ID:/Ruby193/include/rub
y-1.9.1 -LD:/Ruby193/lib -Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb
_require -shared  -Wl,--enable-auto-image-base,--enable-auto-import,--export-all
 -Wl,--out-implib=tmp/exerb53.dll.a -s -o data/exerb/exerb53.dll tmp/resource_dl
l.o src/exerb/exerb.c src/exerb/module.c src/exerb/utility.c src/exerb/patch.c t
mp/exerb53.def -lmsvcrt-ruby191-static -lshell32 -lws2_32 -limagehlp -lshlwapi
src/exerb/exerb.c:49:1: warning: missing braces around initializer
src/exerb/exerb.c:49:1: warning: (near initialization for 'g_loaded_library_tabl
e[0]')
src/exerb/exerb.c:50:1: warning: missing braces around initializer
src/exerb/exerb.c:50:1: warning: (near initialization for 'g_pre_loaded_library_
table[0]')
Creating library file: tmp/exerb53.dll.a
mkdir -p data/exerb
gcc  -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno
-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-s
trings  -DRUBY_EXPORT -DRUBY19 -DRUBY19_COMPILED_CODE -DFD_SETSIZE=2048  -DFD_SE
TSIZE=2048 -ID:/Ruby193/include/ruby-1.9.1/i386-mingw32 -ID:/Ruby193/include/rub
y-1.9.1 -LD:/Ruby193/lib -Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb
_require     -s -o data/exerb/ruby193crt.exc src/exerb/cui.c tmp/resource_cui.o
tmp/exerb53.dll.a  -lshell32 -lws2_32 -limagehlp -lshlwapi
strip -R .reloc data/exerb/ruby193crt.exc
mkdir -p tmp
windres -DGUI src/exerb/resource.rc tmp/resource_gui.o
mkdir -p data/exerb
gcc  -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno
-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-s
trings  -DRUBY_EXPORT -DRUBY19 -DRUBY19_COMPILED_CODE -DFD_SETSIZE=2048  -DFD_SE
TSIZE=2048 -ID:/Ruby193/include/ruby-1.9.1/i386-mingw32 -ID:/Ruby193/include/rub
y-1.9.1 -LD:/Ruby193/lib -Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb
_require  -mwindows   -s -o data/exerb/ruby193g.exc src/exerb/gui.c tmp/resource
_gui.o src/exerb/exerb.c src/exerb/module.c src/exerb/utility.c src/exerb/patch.
c tmp/exerb53.def -lmsvcrt-ruby191-static -lshell32 -lws2_32 -limagehlp -lshlwap
i
src/exerb/exerb.c:49:1: warning: missing braces around initializer
src/exerb/exerb.c:49:1: warning: (near initialization for 'g_loaded_library_tabl
e[0]')
src/exerb/exerb.c:50:1: warning: missing braces around initializer
src/exerb/exerb.c:50:1: warning: (near initialization for 'g_pre_loaded_library_
table[0]')
strip -R .reloc data/exerb/ruby193g.exc
mkdir -p data/exerb
gcc  -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno
-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-s
trings  -DRUBY_EXPORT -DRUBY19 -DRUBY19_COMPILED_CODE -DFD_SETSIZE=2048  -DFD_SE
TSIZE=2048 -ID:/Ruby193/include/ruby-1.9.1/i386-mingw32 -ID:/Ruby193/include/rub
y-1.9.1 -LD:/Ruby193/lib -Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb
_require  -mwindows   -s -o data/exerb/ruby193grt.exc src/exerb/gui.c tmp/resour
ce_gui.o tmp/exerb53.dll.a  -lshell32 -lws2_32 -limagehlp -lshlwapi
strip -R .reloc data/exerb/ruby193grt.exc
==== fake extensions ====
Temporarily enhancing PATH to include DevKit...
generating tmp/exerb53.def
generating header src/exerb/config.h

make


Gem files will remain installed in D:/Ruby193/lib/ruby/gems/1.9.1/gems/exerb-6.0
.1 for inspection.
Results logged to D:/Ruby193/lib/ruby/gems/1.9.1/gems/exerb-6.0.1/./gem_make.out

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册