Windows 7 - building win32/api gem

Discussion in 'Ruby' started by Stanislaw Wozniak, Mar 3, 2009.

  1. Hi Guys,

    I have been trying to install win32-api 1.4.0 gem on windows 7 x64 but
    no success.

    When i install x86 version, require 'win32/api' gives me following
    error:

    LoadError: 193: %1 is not a valid Win32 application. -
    c:/ruby/lib/ruby/gems/1.9.1/gems/win32-api-1.4.0-x86-mswin32-60/lib/win32/api.so
    from (irb):1:in `require'
    from (irb):1
    from c:/ruby/bin/irb.bat:20:in `<main>'

    My ruby:
    ruby 1.9.1p0 (2009-01-30 revision 21907) [x64-mswin64_80]

    My gems:
    1.3.1

    I have VS2008 installed and even managed to create a makefile but it
    complains about following:

    C:\>gem install win32-api
    Building native extensions. This could take a while...
    ERROR: Error installing win32-api:
    ERROR: Failed to build gem native extension.

    c:/ruby/bin/ruby.exe extconf.rb install win32-api
    checking for strncpy_s()... yes
    creating Makefile

    nmake

    Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
    Copyright (C) Microsoft Corporation. All rights reserved.

    c:\ruby\bin\ruby -e "puts 'EXPORTS', 'Init_api'" >
    api-x64-mswin64_80.def
    cl -nologo -I. -Ic:/ruby/include/ruby-1.9.1/x64-mswin64_80
    -Ic:/ruby/include/ruby-1.9.1/ruby/backward -Ic:/ruby/include/ruby-1.9.1
    -Iwin32 -MD -Zi -O2b
    2xty- -Zm600 -DHAVE_STRNCPY_S -D_CRT_SECURE_NO_DEPRECATE
    -D_CRT_NONSTDC_NO_DEPRECATE -Foapi.obj -c -Tcwin32/api.c
    api.c
    cl -nologo -LD -Feapi.so api.obj msvcr80-ruby191.lib
    oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib -link
    -incremental:no -debug -opt:re
    f -opt:icf -dll -libpath:"." -libpath:"c:/ruby/lib"
    -implib:api-x64-mswin64_80.lib -pdb:api-x64-mswin64_80.pdb
    -def:api-x64-mswin64_80.def
    Creating library api-x64-mswin64_80.lib and object
    api-x64-mswin64_80.exp
    api.obj : error LNK2019: unresolved external symbol _rb_num2long
    referenced in function _NUM2LONG
    api.obj : error LNK2019: unresolved external symbol _rb_int2big
    referenced in function _LONG2NUM
    api.obj : error LNK2019: unresolved external symbol _rb_uint2big
    referenced in function _ULONG2NUM
    api.obj : error LNK2019: unresolved external symbol
    _rb_data_object_alloc referenced in function _api_allocate
    api.obj : error LNK2019: unresolved external symbol _rb_raise referenced
    in function _StringError
    api.obj : error LNK2019: unresolved external symbol _rb_iv_set
    referenced in function _callback_init
    api.obj : error LNK2019: unresolved external symbol _rb_str_new_cstr
    referenced in function _callback_init
    api.obj : error LNK2019: unresolved external symbol _rb_scan_args
    referenced in function _callback_init
    api.obj : error LNK2019: unresolved external symbol _rb_string_value_ptr
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_str_cat
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_str_new_shared
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_check_safe_obj
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_string_value
    referenced in function _api_init
    api.obj : error LNK2001: unresolved external symbol __imp__rb_eArgError
    api.obj : error LNK2019: unresolved external symbol _rb_ary_push
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_ary_new
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_str_split
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_respond_to
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_intern
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_check_type
    referenced in function _api_init
    api.obj : error LNK2019: unresolved external symbol _rb_str_modify
    referenced in function _CallbackFunction
    api.obj : error LNK2019: unresolved external symbol _rb_num2ulong
    referenced in function _CallbackFunction
    api.obj : error LNK2019: unresolved external symbol _rb_funcall2
    referenced in function _CallbackFunction
    api.obj : error LNK2019: unresolved external symbol _rb_iv_get
    referenced in function _CallbackFunction
    api.obj : error LNK2019: unresolved external symbol _rb_str_new
    referenced in function _api_call
    api.obj : error LNK2019: unresolved external symbol _rb_define_const
    referenced in function _Init_api
    api.obj : error LNK2019: unresolved external symbol _rb_define_attr
    referenced in function _Init_api
    api.obj : error LNK2019: unresolved external symbol _rb_define_method
    referenced in function _Init_api
    api.obj : error LNK2019: unresolved external symbol
    _rb_define_alloc_func referenced in function _Init_api
    api.obj : error LNK2001: unresolved external symbol
    __imp__rb_eRuntimeError
    api.obj : error LNK2019: unresolved external symbol
    _rb_define_class_under referenced in function _Init_api
    api.obj : error LNK2001: unresolved external symbol __imp__rb_cObject
    api.obj : error LNK2019: unresolved external symbol _rb_define_module
    referenced in function _Init_api
    api.so : fatal error LNK1120: 33 unresolved externals
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
    Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'
    Stop.


    Gem files will remain installed in
    c:/ruby/lib/ruby/gems/1.9.1/gems/win32-api-1.4.0 for inspection.
    Results logged to
    c:/ruby/lib/ruby/gems/1.9.1/gems/win32-api-1.4.0/ext/gem_make.out


    Does anyone have any idea about building gem on windows? Or maybe you
    have precompiled api.so on your x64 system.

    I would appreciate your help.
    --
    Posted via http://www.ruby-forum.com/.
     
    Stanislaw Wozniak, Mar 3, 2009
    #1
    1. Advertising

  2. Stanislaw Wozniak

    Heesob Park Guest

    Hi,

    2009/3/3 Stanislaw Wozniak <>:
    > Hi Guys,
    >
    > I have been trying to install win32-api 1.4.0 gem on windows 7 x64 but
    > no success.
    >
    > When i install x86 version, require 'win32/api' gives me following
    > error:
    >
    > LoadError: 193: %1 is not a valid Win32 application. =C2=A0 -
    > c:/ruby/lib/ruby/gems/1.9.1/gems/win32-api-1.4.0-x86-mswin32-60/lib/win32=

    /api.so
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0from (irb):1:in `require'
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0from (irb):1
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0from c:/ruby/bin/irb.bat:20:in `<main>'
    >
    > My ruby:
    > ruby 1.9.1p0 (2009-01-30 revision 21907) [x64-mswin64_80]
    >
    > My gems:
    > 1.3.1
    >
    > I have VS2008 installed and even managed to create a makefile but it
    > complains about following:
    >
    > C:\>gem install win32-api
    > Building native extensions. =C2=A0This could take a while...
    > ERROR: =C2=A0Error installing win32-api:
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0ERROR: Failed to build gem native extension.
    >
    > c:/ruby/bin/ruby.exe extconf.rb install win32-api
    > checking for strncpy_s()... yes
    > creating Makefile
    >
    > nmake
    >
    > Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
    > Copyright (C) Microsoft Corporation. =C2=A0All rights reserved.
    >
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0c:\ruby\bin\ruby -e "puts 'EXPORTS', 'Init_api=

    '" =C2=A0>
    > api-x64-mswin64_80.def
    > =C2=A0 =C2=A0 =C2=A0 =C2=A0cl -nologo -I. -Ic:/ruby/include/ruby-1.9.1/x6=

    4-mswin64_80
    > -Ic:/ruby/include/ruby-1.9.1/ruby/backward -Ic:/ruby/include/ruby-1.9.1
    > -Iwin32 -MD -Zi =C2=A0-O2b
    > 2xty- =C2=A0-Zm600 -DHAVE_STRNCPY_S -D_CRT_SECURE_NO_DEPRECATE
    > -D_CRT_NONSTDC_NO_DEPRECATE -Foapi.obj -c -Tcwin32/api.c
    > api.c

    ...
    >
    > Does anyone have any idea about building gem on windows? Or maybe you
    > have precompiled api.so on your x64 system.
    >

    I guess you tried to build win32-api module with Visual C++ 9.0.
    You must use the same compiler with the Ruby version(x64-mswin64_80).
    After some trials and errors, I managed to build win32-api module with
    Visual C++ 8.0.
    You can download at http://121.78.227.9/win32-api-1.4.0/lib/win32/api.so

    NB, Using win32utils on the 64bit Ruby is not tested.

    Regards,

    Park Heesob
     
    Heesob Park, Mar 3, 2009
    #2
    1. Advertising

  3. Thanks for your help, it worked like a charm.

    For my future reference, is VC++ 8.0 included in Visual Studio 2005?
    --
    Posted via http://www.ruby-forum.com/.
     
    Stanislaw Wozniak, Mar 3, 2009
    #3
  4. And BTW, would you mind sharing how to setup build environment and how
    to build extensions on windows? I am installing VS2005 as we speak
    --
    Posted via http://www.ruby-forum.com/.
     
    Stanislaw Wozniak, Mar 3, 2009
    #4
  5. Stanislaw Wozniak

    Heesob Park Guest

    Hi,

    2009/3/4 Stanislaw Wozniak <>:
    > And BTW, would you mind sharing how to setup build environment and how
    > to build extensions on windows? I am installing VS2005 as we speak


    Build environment is just Visual Studio 2005 x64 command prompt.

    The ruby 1.9.1p0 (2009-01-30 revision 21907) [x64-mswin64_80] distribution lacks
    win32.h file in \include\ruby-1.9.1\ruby folder.
    Coping win32.h from ruby 1.9.1p0 source code to the above folder is required.

    This subject is more suitable on win32utils-devel mailing list.
    Please join at http://rubyforge.org/mail/?group_id=85 for more discussion.

    Regards,

    Park Heesob
     
    Heesob Park, Mar 4, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clifford Heath
    Replies:
    7
    Views:
    318
    Shanti Braford
    Jun 9, 2006
  2. Austin 7873
    Replies:
    5
    Views:
    198
    Eric Hodel
    Jan 27, 2007
  3. Replies:
    2
    Views:
    159
    bbiker
    Oct 25, 2007
  4. Manuel Souto Pico
    Replies:
    2
    Views:
    183
    Marvin Gülker
    Aug 11, 2009
  5. Mike G.
    Replies:
    5
    Views:
    183
    Daniel Berger
    Oct 28, 2010
Loading...

Share This Page