Manually Load Shared Library in Ruby

Recently I needed to run a Ruby script that required the openssl library for communications. However after setting up Ruby on Mac OS X for the first time and succeeding in installing all the required gems, the following error kept popping.

dyld: lazy symbol binding failed: Symbol not found: _SSL_library_init

I couldn’t find much help online and I have no idea yet how to actually debug linker problems with the ruby system. However I figured out a quick and easy way to overcome the error.

require 'dl'
ssl = DL::dlopen('/usr/lib/libssl.dylib');