Ruby extension

License

Copyright (c) 2007, Benjamin April, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the author(s) nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Support

  • Contact author for support.

Download

Comments

Compile on Ubuntu
carlskiicarlskii 1209233352|%e %b %Y, %H:%M %Z|agohover

Hi,

I'm trying to compile this wrapper on Ubuntu and it keeps failing. Are there any specific build instructions?

I have ruby and ruby-dev installed.

Best Regards,

Carl

Reply  |  Options
Unfold Compile on Ubuntu by carlskiicarlskii, 1209233352|%e %b %Y, %H:%M %Z|agohover
How to build ruby Extension
Eranga SamararathnaEranga Samararathna 1212672145|%e %b %Y, %H:%M %Z|agohover

1.) Install ruby-full in your machine.
I would suggest to use something like "sudo apt-get install ruby-full "

2.)Open the "amq_client.c" file.
Change the line 197 as follows

old -> rb_define_method(amqp_connection,"client_session_new", con_client_session_new,0);
new-> rb_define_method(amqp_connection,"client_session_new", con_client_session_new,1);

2.)Remove the Makefile in the distribution.

3.)Open extconf.rb in a text editor.
Chnage it to

require 'mkmf'
$INCFLAGS += ' -I${AMQ_HOME}/include'
$LIBS += ' -L${AMQ_HOME}/lib -Wl,-rpath=${AMQ_HOME}/lib -lamq_wireapi -lamq_common -lsmt -licl -lipr -lasl -lapr -laprutil -lpcre'
create_makefile("open_amqp")

4.)Set OpenAMQ home
export AMQ_HOME=/opt/amq

5.)Generate make file using command
ruby extconf.rb

6.)Build ruby library using command
make all

7.)Start your OpenAMQ server
cd ${AMQ_HOME}/bin/
./amq_server

8.)Open the test.rb file
Change the line 14 as follows

old -> auth_data = foo.client_connection_auth_plain("guest","foobar")
new -> auth_data = foo.client_connection_auth_plain("guest","guest")

Comment the line 17

Change the line 20 as follows

old -> session = connection.client_session_new
new -> session = connection.client_session_new(connection)

Save your changes.

9.) Run sample program
ruby test.rb

10.) Enjoy ! :)

Regards,

Eranga

http://www.erangac.blogspot.com/

Reply  |  Options
Unfold How to build ruby Extension by Eranga SamararathnaEranga Samararathna, 1212672145|%e %b %Y, %H:%M %Z|agohover
Re: How to build ruby Extension
juvanhamjuvanham 1236867795|%e %b %Y, %H:%M %Z|agohover

I'm trying to use ruby with OpenAMQ-1.3c5.tar.gz and like to share a few small improvements for the tips above.

step 2 above modifies the ruby API but since this is a method of connection the modification can be better:
amq_connection.h:126 remove second parameter from this function
amq_connection.h:132 change the first parameter to self

the connection object is already known so the change above could allow something inconsistent where the object and the argument are different.

in step 8 the change in line 20 will be no longer needed

to make the binding compile I needed to change $AMQ_HOME/include/apr.h:270 in such way that __off64_t is used instead of off64_t. This must be the same after including 'sys/types.h' but for some reason it doesn't work always.

Line 16 of test.rb call connection.error_text but this leads to a segfault, after removing this line it worked, until I find a better way to fix this problem.

Reply  |  Options
Unfold Re: How to build ruby Extension by juvanhamjuvanham, 1236867795|%e %b %Y, %H:%M %Z|agohover
Build ruby extension with OpenAMQ-1.2d1 in Intel 64 bit system
Eranga SamararathnaEranga Samararathna 1221542766|%e %b %Y, %H:%M %Z|agohover

If you try to build the ruby extension with OpenAMQ-1.2d1 in Intel 64 bit system you will probably end up with a following error.

relocation R_X86_64_32 against ‘a local symbol’ can not be used when making a shared object; recompile with -fPIC
/opt/ibaseold//lib/libamq_wireapi.a: could not read symbols: Bad value

You can an idea about this error from the following link.
http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3#doc_chap7

How could you overcome this issue?
Rebuild the OpenAMQ-1.2d1 with following additional options.

export CCDEFINES="-fPIC"
export CFLAGS="-fPIC"
export BASE_THREADSAFE="-DBASE_THREADSAFE"

Then follow the regular build steps.

Then you need to follow the instruction I was given in my previous post.

Regards,

Eranga

http://www.erangac.blogspot.com/

Reply  |  Options
Add a New Comment

Edit | Files | Tags | Source | Print

rating: +2+x

Author

Benjamin April <moc.liamg|lirpab#moc.liamg|lirpab>

All add-ons

Ruby extension: This is a simple C extension to Ruby that wraps WireAPI.

Win32 builds with DLLs: This package provides Win32 builds of the OpenAMQ software including DLLs.