reidmorrison / rubywmq

Ruby interface into WebSphere MQ
https://github.com/reidmorrison/rubywmq
Apache License 2.0
32 stars 24 forks source link

Unable to install and run on Windows Server #9

Closed patrickboe closed 10 years ago

patrickboe commented 10 years ago

I'm running Windows Server 2008 R2 on my development machine. WMQ Server 7.5 is installed in its default location, C:\Program Files (x86)\IBM\WebSphere MQ. When I run gem install rubywmq --platform=ruby, there is an error looking for headers in C:\Program Files[...]\include.

Following the advice on the README, I ran ruby extconf.rb --with-mqm-include="C:\Program Files (x86)\IBM\WebSphere MQ\Tools\c\include", but extconf.rb still looked for the headers in Program Files and errored out. Next, I manually edited extconf.rb to use Program Files (x86) and then ran ruby extconf.rb --with-mqm-include="C:\Program Files\IBM\WebSphere MQ\Tools\c\include" without an error.

The README then says to run nmake. When I do this, I get makefile(82) : fatal error U1000: syntax error : ')' missing in macro invocation. As an alternative, I tried just running make, which worked with no errors but a bunch of warnings. However, when I try the sample code in the README under "Verifying the build", calling require 'wmq' elicits a "cannot load such file" error.

Please let me know if I can be of any assistance in researching this issue further.

reidmorrison commented 10 years ago

Is the MQ SDK installed and the headers files present? If so, can you attach the complete output from the gem install?

patrickboe commented 10 years ago

Sure - the following is from running gem install on the unedited gem. As mentioned above, I went on to edit extconf.rb to use "Program Files (x86)" but then got a syntax error on nmake.

C:\RubyDev\Kit32>gem install rubywmq --platform=ruby
Fetching: rubywmq-2.0.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rubywmq:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb
checking for cmqc.h... no
checking for main() in -lmqm... no
*** 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:/Ruby193/bin/ruby
        --with-mqm-dir
        --without-mqm-dir
        --with-mqm-include
        --without-mqm-include=${mqm-dir}/include
        --with-mqm-lib
        --without-mqm-lib=${mqm-dir}/lib
        --with-mqmlib
        --without-mqmlib
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/generate_reason.r
b:6:in `initialize': No such file or directory - C:\Program Files\IBM\WebSphere
MQ\tools\c\include/cmqc.h (Errno::ENOENT)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:6:in `open'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:6:in `extract_const'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:26:in `reason_case'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:70:in `block in wmq_reason'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:68:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:68:in `wmq_reason'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:224:in `block in generate'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:224:in `open'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/generate/gene
rate_reason.rb:224:in `generate'
        from extconf.rb:27:in `<main>'

Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2
.0.2 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubywmq-2.0.2/ext/gem_make
.out
patrickboe commented 10 years ago

Sorry, forgot to answer the first part of your question. I believe the SDK is installed. The directory C:\Program Files (x86)\IBM\WebSphere MQ\tools\c\include exists and contains these items:

amqsvmha.h
cmqbc.h
cmqc.h
cmqcfc.h
cmqec.h
cmqpsc.h
cmqxc.h
cmqzc.h
reidmorrison commented 10 years ago

On Windows it looks like you have to edit extconf.rb to make it change the path of where MQ is installed.

Open a command prompt, run these commands after changing the paths to your setup:

C:\>cd C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.2\ext

C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.2\ext>C:\Devkit\devkitvars.bat
Adding the DevKit to PATH...

After editing the following line in extconf.rb to set the new path:

  include_path = 'C:\Program Files (x86)\IBM\WebSphere MQ\tools\c\include'

Run extconf to build a make file

C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.2\ext>ruby extconf.rb
checking for cmqc.h... yes
checking for main() in -lmqm... no
Generated wmq_reason.c
Generated wmq_const_admin.rb
Generated wmq_const.rb
Generated wmq_structs.c
creating Makefile

Wipe any previous partial build

make clean

Build the shared library

make

You need the extconf step to work before running make.

Also check mkmf.log for any errors.

nmake must be from one of your other tools:

C:\Ruby193\lib\ruby\gems\1.9.1\gems\rubywmq-2.0.2\ext>nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.
reidmorrison commented 10 years ago

If you are running bundler can you try adding the github repo directly and see if the change I just made works for you?

In Gemfile:

gem 'rubywmq', git: 'git@github.com:reidmorrison/rubywmq.git'

Then run

bundle install

The change just committed to that branch should detect the x86 path first and use it for the include files.

patrickboe commented 10 years ago

I had to change that to https@... from git@... to avoid a Permission denied (publickey). Then...

~> bundle install
Fetching https://github.com/reidmorrison/rubywmq.git
remote: Reusing existing pack: 471, done.
remote: Total 471 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (471/471), 212.45 KiB | 0 bytes/s, done.
Resolving deltas: 100% (279/279), done.
There was a LoadError while loading rubywmq.gemspec:
cannot load such file -- rubywmq/version from
c:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/rubywmq-71e7f7ed0c0f/rubywmq.gemspec:4:in
`<main>'

Does it try to require a relative path? That's been removed in Ruby 1.9.

Not sure if it's because of the require 'rubywmq/version' - looking into alternatives now.

patrickboe commented 10 years ago

I've got a patch to fix the bug, but I have to run the pull request past my employer before submitting it.