本文介绍了在Windows 7 x86上使用Ruby for Event Machine安装OpenSSL和Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 7 x86上为事件机安装带有Ruby的OpenSSL.
我想在Windows 7 x86 SP1上安装eventmachine gem.
我已经从 http://rubyinstaller.org/downloads/
安装了rubyinstaller-2.1.5.exe我还安装了DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe.

Install OpenSSL with Ruby for eventmachine on Windows 7 x86.
I want to install eventmachine gem on Windows 7 x86 SP1.
I have installed rubyinstaller-2.1.5.exe from http://rubyinstaller.org/downloads/
I have also installed DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe.

我运行命令:

gem install eventmachine --platform=ruby

目前,这是使用eventmachine-1.0.4.

我得到了以下控制台输出:

I got following console output:

    Temporarily enhancing PATH to include DevKit...
    Building native extensions.  This could take a while...
    ERROR:  Error installing eventmachine:
            ERROR: Failed to build gem native extension.

        C:/Ruby21/bin/ruby.exe extconf.rb
    checking for main() in -lssl... no
    checking for rb_trap_immediate in ruby.h,rubysig.h... no
    checking for rb_thread_blocking_region()... yes
    checking for ruby/thread.h... yes
    checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
    checking for inotify_init() in sys/inotify.h... no
    checking for __NR_inotify_init in sys/syscall.h... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.

    Provided configuration options:
            --with-opt-dir
            --without-opt-dir
            --with-opt-include
            --without-opt-include=${opt-dir}/include
            --with-opt-lib
            --without-opt-lib=${opt-dir}/lib
            --with-make-prog
            --without-make-prog
            --srcdir=.
            --curdir
            --ruby=C:/Ruby21/bin/ruby
            --with-openssl-config
            --without-openssl-config
            --with-pkg-config
            --without-pkg-config
            --with-ssl-dir
            --without-ssl-dir
            --with-ssl-include
            --without-ssl-include=${ssl-dir}/include
            --with-ssl-lib
            --without-ssl-lib=${ssl-dir}/lib
            --with-ssllib
            --without-ssllib
    C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:395:in `system': Invalid argument - ruby_setenv(LOGONSERVER) (Errno::EINVAL)
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:395:in `block in xsystem'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:321:in `open'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:385:in `xsystem'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:463:in `try_do'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:571:in `block in try_compile'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:524:in `with_werror'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:571:in `try_compile'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:811:in `macro_defined?'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:950:in `block in have_macro'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:321:in `open'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:321:in `open'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
            from C:/Ruby21/lib/ruby/2.1.0/mkmf.rb:949:in `have_macro'
            from extconf.rb:72:in `<main>'

    extconf failed, exit code 1

    Gem files will remain installed in C:/Ruby21/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.4 for inspection.
    Results logged to C:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/eventmachine-1.0.4/gem_make.out

文件C:\Ruby21\lib\ruby\gems\2.1.0\extensions\x86-mingw32\2.1.0\eventmachine-1.0.4\mkmf.log如下:

    package configuration for openssl is not found
    have_library: checking for main() in -lssl... -------------------- no

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <winsock2.h>
    4: #include <windows.h>
    5: int main(int argc, char **argv)
    6: {
    7:   return 0;
    8: }
    /* end */

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lssl -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c: In function 't':
    conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    c:/rubydevkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lssl
    collect2.exe: error: ld returned 1 exit status
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5:
     6: /*top*/
     7: extern int t(void);
     8: int main(int argc, char **argv)
     9: {
    10:   if (argc > 1000000) {
    11:     printf("%p", &t);
    12:   }
    13:
    14:   return 0;
    15: }
    16: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
    /* end */

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lssl -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c: In function 't':
    conftest.c:16:1: error: too few arguments to function 'main'
    conftest.c:8:5: note: declared here
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5:
     6: /*top*/
     7: extern int t(void);
     8: int main(int argc, char **argv)
     9: {
    10:   if (argc > 1000000) {
    11:     printf("%p", &t);
    12:   }
    13:
    14:   return 0;
    15: }
    16: int t(void) { main(); return 0; }
    /* end */

    --------------------

    have_var: checking for rb_trap_immediate in ruby.h,rubysig.h... -------------------- no

    "gcc -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration   -c conftest.c"
    In file included from conftest.c:6:0:
    C:/Ruby21/include/ruby-2.1.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
    conftest.c: In function 't':
    conftest.c:18:55: error: 'rb_trap_immediate' undeclared (first use in this function)
    conftest.c:18:55: note: each undeclared identifier is reported only once for each function it appears in
    conftest.c:18:45: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5: #include <ruby.h>
     6: #include <rubysig.h>
     7:
     8: /*top*/
     9: extern int t(void);
    10: int main(int argc, char **argv)
    11: {
    12:   if (argc > 1000000) {
    13:     printf("%p", &t);
    14:   }
    15:
    16:   return 0;
    17: }
    18: int t(void) { const volatile void *volatile p; p = &(&rb_trap_immediate)[0]; return 0; }
    /* end */

    --------------------

    have_func: checking for rb_thread_blocking_region()... -------------------- yes

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c: In function 't':
    conftest.c:16:1: warning: 'rb_thread_blocking_region' is deprecated (declared at C:/Ruby21/include/ruby-2.1.0/ruby/intern.h:870) [-Wdeprecated-declarations]
    conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5:
     6: /*top*/
     7: extern int t(void);
     8: int main(int argc, char **argv)
     9: {
    10:   if (argc > 1000000) {
    11:     printf("%p", &t);
    12:   }
    13:
    14:   return 0;
    15: }
    16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
    /* end */

    --------------------

    have_header: checking for ruby/thread.h... -------------------- yes

    "gcc -E -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  conftest.c -o conftest.i"
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <winsock2.h>
    4: #include <windows.h>
    5: #include <ruby/thread.h>
    /* end */

    --------------------

    have_func: checking for rb_thread_call_without_gvl() in ruby/thread.h... -------------------- yes

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c: In function 't':
    conftest.c:17:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5: #include <ruby/thread.h>
     6:
     7: /*top*/
     8: extern int t(void);
     9: int main(int argc, char **argv)
    10: {
    11:   if (argc > 1000000) {
    12:     printf("%p", &t);
    13:   }
    14:
    15:   return 0;
    16: }
    17: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return 0; }
    /* end */

    --------------------

    have_func: checking for inotify_init() in sys/inotify.h... -------------------- no

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c:5:25: fatal error: sys/inotify.h: No such file or directory
    compilation terminated.
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5: #include <sys/inotify.h>
     6:
     7: /*top*/
     8: extern int t(void);
     9: int main(int argc, char **argv)
    10: {
    11:   if (argc > 1000000) {
    12:     printf("%p", &t);
    13:   }
    14:
    15:   return 0;
    16: }
    17: int t(void) { void ((*volatile p)()); p = (void ((*)()))inotify_init; return 0; }
    /* end */

    "gcc -o conftest.exe -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby21/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
    conftest.c:5:25: fatal error: sys/inotify.h: No such file or directory
    compilation terminated.
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5: #include <sys/inotify.h>
     6:
     7: /*top*/
     8: extern int t(void);
     9: int main(int argc, char **argv)
    10: {
    11:   if (argc > 1000000) {
    12:     printf("%p", &t);
    13:   }
    14:
    15:   return 0;
    16: }
    17: int t(void) { inotify_init(); return 0; }
    /* end */

    --------------------

    "gcc -IC:/Ruby21/include/ruby-2.1.0/i386-mingw32 -IC:/Ruby21/include/ruby-2.1.0/ruby/backward -IC:/Ruby21/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration   -c conftest.c"
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: #include <winsock2.h>
     4: #include <windows.h>
     5: #include <sys/syscall.h>
     6: /*top*/
     7: #ifndef __NR_inotify_init
     8: # error
     9: |:/ === __NR_inotify_init undefined === /:|
    10: #endif
    /* end */

根据此输出,我需要安装OpenSSL.很有可能添加必需的OpenSSL支持并不能解决所有棘手的错误,但是我从此开始.

Accoding to this output I need to install OpenSSL. Most probably adding required OpenSSL support does not resolve all obrained errors, but I started from it.

我已阅读此帖子 https://github.com/eventmachine/eventmachine/issues/555#issuecomment-68942305 .但是这种解决方案看起来很脏.不是吗?
我继续这篇文章 https://github.com/eventmachine/eventmachine/Issues/555#issuecomment-68945346 并最终对此线程 https://groups.google.com/forum/#!topic/rubyinstaller/qVBRWlHb86Y/discussion .
我在此处阅读以下内容:如果您仅使用RubyInstaller,请仅从bin文件夹内的软件包(使用7-Zip)中提取DLL."
提取的文件应该放在哪里?我试图将其放入C:\Ruby21\binC:\RubyDevKit\bin-没有任何变化.

I have read this post https://github.com/eventmachine/eventmachine/issues/555#issuecomment-68942305 . But this solution looks dirty. No?
I go ahead to this post https://github.com/eventmachine/eventmachine/issues/555#issuecomment-68945346 and eventually to this thread https://groups.google.com/forum/#!topic/rubyinstaller/qVBRWlHb86Y/discussion .
I read the following there: "If you're just using RubyInstaller, extract only the DLLs from the package (using 7-Zip) located inside the bin folder."
Where should I put extracted files? I tried to put it to C:\Ruby21\bin and C:\RubyDevKit\bin - nothing changes.

如何解决这些错误?
非常感谢!

How should I fix these errors?
Thanks a lot!

我尝试了其他选择,例如在 Ruby中进行了介绍:Ruby:在Windows 7下安装EventMachine时出现问题.

I tried other options, e.g. described at Ruby: problem installing EventMachine under Windows 7 .

某些背景:
这是mysql2 gem(取决于eventmachine)所必需的,在我的情况下最终是redmine所必需的.
我不是红宝石程序员.

Some background:
This is required by mysql2 gem (which depends on eventmachine) and eventually by redmine in my case.
I am not ruby programmer.

推荐答案

我正在尝试使用rubyinstaller-2.1.6.exe,DevKit-mingw64-32-4.7.2-20130224-1151-sfx做同样的事情. exe和OpenSSL( http://slproweb.com/download/Win32OpenSSL-1_0_2c.exe或从不)在C:\ OpenSSL

I am trying to do the same thing using rubyinstaller-2.1.6.exe, DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe and OpenSSL (http://slproweb.com/download/Win32OpenSSL-1_0_2c.exe or never) in C:\OpenSSL

gem install eventmachine -- --with-ssl-dir=C:\OpenSSL

成功,但随后通过ssl进行瘦身操作通常会失败:

succeeds but then running thin with ssl fails in usual manner:

Encryption not available on this event-machine

您在上方看到了如何将参数传递给本机gem设置,这将对您有所帮助.我们仍然需要找到一组可以正确构建事物的参数.

You see above how to pass parameter to the native gem setup which should help you. We still need to find a set of parameters which will allow to built the thing correctly.

制作方法

checking for main() in -lssl... no

是的...?

经过半天的挖掘,我修补了eventmachine,以正确搜索Windows上的ssl库,因此请在gemfile中使用以下行,直到合并更改为止:

after half a day of digging I have patched eventmachine to correctly search for ssl libs on windows so use below line in gemfile until changes are merged:

gem 'eventmachine', :github => 'krzcho/eventmachine', :branch => 'master'

在安装捆绑软件之前,请指定ssl的位置(它必须是具有开发人员标头/库的ssl的完整版本)

before installing the bundle specify location of ssl (it must be full version of ssl with developer headers/libs)

bundle config build.eventmachine --with-ssl-dir=c:/OpenSSL

我还需要使自己变瘦,这不会激活另一个事件机,因此需要在gemfile中添加另一行:

i also needed to make my own thin which is not activating another eventmachine so another line in gemfile is needed:

gem 'thin', :github => 'krzcho/thin', :branch => 'master'

不幸的是,当我使用非自签名证书时仍然遇到问题: Windows上的瘦轨服务器/事件机不起作用带有自定义证书的(案例关闭-错误的证书)

unfortunately i still have problem when using non-self signed cert:thin rails server/eventmachine on windows does not work with custom certificate (case closed - wrong cert)

这篇关于在Windows 7 x86上使用Ruby for Event Machine安装OpenSSL和Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 06:29