[newbie] help, I can't compile an extension on windows

Discussion in 'Ruby' started by Lionel Thiry, Jun 1, 2005.

  1. Lionel Thiry

    Lionel Thiry Guest

    Hello!

    I'm on Windows2000, with ruby 1.8.2 (2004-12-25) [i386-mswin32]
    (on-click-installer). I have latest mingw and VC++ installed (the
    command line version) and vars are set: PATH to each bin dirs, LIB to
    each lib dirs and INCLUDE to each include dirs.

    I've written in a file the first sample found in pragmatic programmer's
    book: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
    ----8<----
    #include "ruby.h"


    static VALUE t_init(VALUE self)
    {
    VALUE arr;


    arr = rb_ary_new();
    rb_iv_set(self, "@arr", arr);
    return self;
    }


    static VALUE t_add(VALUE self, VALUE anObject)
    {
    VALUE arr;


    arr = rb_iv_get(self, "@arr");
    rb_ary_push(arr, anObject);
    return arr;
    }


    VALUE cTest;


    void Init_Test() {
    cTest = rb_define_class("Test", rb_cObject);
    rb_define_method(cTest, "initialize", t_init, 0);
    rb_define_method(cTest, "add", t_add, 1);
    }
    ----8<----

    My first attempt was with the extconf.rb written this way:
    ----8<----
    require 'mkmf'
    create_makefile("Test")
    ----8<----

    I launch it, I then launch make (the mingw version of make, I don't have
    M$ make. Someone know where I can freely get it?)

    And I get this error:
    ----8<----
    >make

    makefile:105: *** multiple target patterns. Stop.
    ----8<----

    I'm not a make expert and I feel hard to see where the error truly lies.

    I then tried it manually, as I read it on the same pragprog page (with
    readaptation for my directory structure):
    ----8<----
    >gcc -fPIC -IC:\usr\ruby\lib\ruby\1.8\i386-mswin32 -g -O2 -c

    first_prag_sample.c -o first_prag_sample.o
    cc1.exe: warning: -fPIC ignored for target (all code is position
    independent)
    In file included from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:670,
    from first_prag_sample.c:1:
    C:/usr/ruby/lib/ruby/1.8/i386-mswin32/missing.h:64:1: warning: "isinf"
    redefined

    In file included from
    C:/usr/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:56,
    from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/defines.h:184,
    from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:22,
    from first_prag_sample.c:1:
    C:/usr/MinGW/include/math.h:290:1: warning: this is the location of the
    previous
    definition
    ----8<----

    And then the second command line:
    ----8<----
    gcc -shared -o Test.so first_prag_sample.o -lc
    C:\usr\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe:
    cannot find -lc

    ----8<----

    Any clues? Any tips? Perhaps a way to do it easier with rake or rant?

    --
    Lionel Thiry

    Personal website: http://users.skynet.be/lthiry/
    Lionel Thiry, Jun 1, 2005
    #1
    1. Advertising

  2. Re: help, I can't compile an extension on windows

    Lionel Thiry wrote:
    > Hello!
    >
    > I'm on Windows2000, with ruby 1.8.2 (2004-12-25) [i386-mswin32]
    > (on-click-installer). I have latest mingw and VC++ installed (the
    > command line version) and vars are set: PATH to each bin dirs, LIB to
    > each lib dirs and INCLUDE to each include dirs.
    >
    > I've written in a file the first sample found in pragmatic programmer's
    > book: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html


    <snip>

    IIRC, your problem is caused by the word "Test". I think it conflicts
    with Kernel.test or something strange. Try changing it to "Foo" and
    see how it goes. I may be off.

    > I launch it, I then launch make (the mingw version of make, I don't have
    > M$ make. Someone know where I can freely get it?)


    http://www.rubygarden.org/ruby?WindowsCompiler

    If you follow these instructions, you should have nmake.

    Regards,

    Dan
    Daniel Berger, Jun 2, 2005
    #2
    1. Advertising

  3. Lionel Thiry

    Lionel Thiry Guest

    Re: help, I can't compile an extension on windows

    Daniel Berger a écrit :
    > Lionel Thiry wrote:
    >
    >>Hello!
    >>
    >>I'm on Windows2000, with ruby 1.8.2 (2004-12-25) [i386-mswin32]
    >>(on-click-installer). I have latest mingw and VC++ installed (the
    >>command line version) and vars are set: PATH to each bin dirs, LIB to
    >>each lib dirs and INCLUDE to each include dirs.
    >>
    >>I've written in a file the first sample found in pragmatic programmer's
    >>book: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

    >
    >
    > <snip>
    >
    > IIRC, your problem is caused by the word "Test". I think it conflicts
    > with Kernel.test or something strange. Try changing it to "Foo" and
    > see how it goes. I may be off.


    Replaced all occurences of Test by Foo. The error is still exactly the same.

    ----8<----
    >make

    makefile:105: *** multiple target patterns. Stop.
    ----8<----

    >>I launch it, I then launch make (the mingw version of make, I don't have
    >>M$ make. Someone know where I can freely get it?)

    >
    >
    > http://www.rubygarden.org/ruby?WindowsCompiler
    >
    > If you follow these instructions, you should have nmake.

    Thank for the tip.

    >
    > Regards,
    >
    > Dan
    >


    Regards
    --
    Lionel Thiry

    Personal website: http://users.skynet.be/lthiry/
    Lionel Thiry, Jun 2, 2005
    #3
  4. Re: help, I can't compile an extension on windows

    Hi,

    At Thu, 2 Jun 2005 08:20:23 +0900,
    Lionel Thiry wrote in [ruby-talk:144281]:
    > ----8<----
    > >make

    > makefile:105: *** multiple target patterns. Stop.
    > ----8<----
    >
    > >>I launch it, I then launch make (the mingw version of make, I don't have
    > >>M$ make. Someone know where I can freely get it?)


    Makefile generated by mkmf.rb for nmake can't work with other makes.

    `extconf.rb --with-make-prog=make' might help you, though I'm not
    sure.

    --
    Nobu Nakada
    nobuyoshi nakada, Jun 2, 2005
    #4
  5. Lionel Thiry

    Lionel Thiry Guest

    Re: help, I can't compile an extension on windows

    nobuyoshi nakada a écrit :
    > Hi,
    >
    > At Thu, 2 Jun 2005 08:20:23 +0900,
    > Lionel Thiry wrote in [ruby-talk:144281]:
    >
    >>----8<----
    >>
    >>>make

    >>
    >>makefile:105: *** multiple target patterns. Stop.
    >>----8<----
    >>
    >>
    >>>>I launch it, I then launch make (the mingw version of make, I don't have
    >>>>M$ make. Someone know where I can freely get it?)

    >
    >
    > Makefile generated by mkmf.rb for nmake can't work with other makes.
    >
    > `extconf.rb --with-make-prog=make' might help you, though I'm not
    > sure.
    >


    Unfortunately, it doesn't work.

    Seems I'm going to dive into mkmf sources.

    --
    Lionel Thiry

    Personal website: http://users.skynet.be/lthiry/
    Lionel Thiry, Jun 2, 2005
    #5
  6. Lionel Thiry

    Lionel Thiry Guest

    Re: help, I can't compile an extension on windows

    Daniel Berger a écrit :
    > Lionel Thiry wrote:
    >>I launch it, I then launch make (the mingw version of make, I don't have
    >>M$ make. Someone know where I can freely get it?)

    >
    >
    > http://www.rubygarden.org/ruby?WindowsCompiler
    >
    > If you follow these instructions, you should have nmake.
    >


    I have it now, and it still don't work. There is something about a
    missing windows.h that I can't find anywhere. I can't find excepted in
    my MinGw include dir, but if I add it to the INCLUDE var, I get another
    bunch of errors (probably some kind of incompatibilities between cl
    compiler and mingw headers)

    --
    Lionel Thiry

    Personal website: http://users.skynet.be/lthiry/
    Lionel Thiry, Jun 5, 2005
    #6
  7. Lionel Thiry

    ES Guest

    Re: help, I can't compile an extension on windows

    Le 5/6/2005, "Lionel Thiry" <> a
    =E9crit:
    >Daniel Berger a =E9crit :
    >> Lionel Thiry wrote:
    >>>I launch it, I then launch make (the mingw version of make, I don't have
    >>>M$ make. Someone know where I can freely get it?)

    >>
    >>
    >> http://www.rubygarden.org/ruby?WindowsCompiler
    >>
    >> If you follow these instructions, you should have nmake.
    >>

    >
    >I have it now, and it still don't work. There is something about a
    >missing windows.h that I can't find anywhere. I can't find excepted in
    >my MinGw include dir, but if I add it to the INCLUDE var, I get another
    >bunch of errors (probably some kind of incompatibilities between cl
    >compiler and mingw headers)


    You should not be mixing cl and MinGW... use whichever tool your
    version of Ruby was compiled with. You can get the MS tools as a
    free (your soul does not count) download if you need them.

    >Lionel Thiry


    E

    --
    template<typename duck>
    void quack(duck& d) { d.quack(); }
    ES, Jun 6, 2005
    #7
  8. Re: help, I can't compile an extension on windows

    Hi,

    At Fri, 3 Jun 2005 07:40:23 +0900,
    Lionel Thiry wrote in [ruby-talk:144419]:
    > > Makefile generated by mkmf.rb for nmake can't work with other makes.
    > >
    > > `extconf.rb --with-make-prog=make' might help you, though I'm not
    > > sure.
    > >

    >
    > Unfortunately, it doesn't work.


    I'll consider about it later, but mingw doesn't support msvcr7 runtime
    yet, which is used by VisualC++ 7 or later.

    --
    Nobu Nakada
    nobuyoshi nakada, Jun 6, 2005
    #8
  9. Lionel Thiry

    Lionel Thiry Guest

    Re: help, I can't compile an extension on windows

    ES a écrit :
    > Le 5/6/2005, "Lionel Thiry" <> a
    > écrit:
    >
    >>Daniel Berger a écrit :
    >>
    >>>Lionel Thiry wrote:
    >>>
    >>>>I launch it, I then launch make (the mingw version of make, I don't have
    >>>>M$ make. Someone know where I can freely get it?)
    >>>
    >>>
    >>>http://www.rubygarden.org/ruby?WindowsCompiler
    >>>
    >>>If you follow these instructions, you should have nmake.
    >>>

    >>
    >>I have it now, and it still don't work. There is something about a
    >>missing windows.h that I can't find anywhere. I can't find excepted in
    >>my MinGw include dir, but if I add it to the INCLUDE var, I get another
    >>bunch of errors (probably some kind of incompatibilities between cl
    >>compiler and mingw headers)

    >
    >
    > You should not be mixing cl and MinGW...


    I haven't. This what I tried to explained: if I mix them, I get errors,
    so I don't.

    > use whichever tool your
    > version of Ruby was compiled with. You can get the MS tools as a
    > free (your soul does not count) download if you need them.


    I already have all the MS tools I should use: nmake, cl, link, and the
    headers and libs, and so on. But I got the error of windows.h missing,
    and there are no windows.h anywhere in MS include stuff.


    --
    Lionel Thiry

    Personal website: http://users.skynet.be/lthiry/
    Lionel Thiry, Jun 6, 2005
    #9
    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. live your lives
    Replies:
    2
    Views:
    2,767
    live your lives
    Aug 25, 2004
  2. Anand
    Replies:
    3
    Views:
    885
    Tim Daneliuk
    Nov 8, 2003
  3. Christian Seberino
    Replies:
    3
    Views:
    1,177
    Christian Seberino
    Feb 5, 2004
  4. Nagaraj
    Replies:
    1
    Views:
    852
    Lionel B
    Mar 1, 2007
  5. Shin guey Wong
    Replies:
    0
    Views:
    121
    Shin guey Wong
    Jun 2, 2008
Loading...

Share This Page