require 'dl' doesn't work

48 views
Skip to first unread message

Liz Huang

unread,
Jul 14, 2014, 11:32:51 AM7/14/14
to rubyonra...@googlegroups.com

In Ruby 1.8.7 and Rails 2.3.18, I used Dl.dlopen to load intel fortran dll like the following

require 'dl'
...

      sspath = Pathname.new( ".../lib/libsamplesize.dylib" )
      ss = DL.dlopen( sspath )
      samplesize = ss[ "samplesize_", "iiddS" ]
      session[:n], args = samplesize[ session[:nmax], session[:delta],
                          session[:conf], session[:errmsg] ]

but I got error message at line

require 'dl'

This error occurred while loading the following files:
   dl

Thanks!
Liz




Liz Huang

unread,
Jul 14, 2014, 12:09:21 PM7/14/14
to rubyonra...@googlegroups.com

I am using Ruby 2.1.0 and Rails 4.1.2 now, and 'dl' no longer works?

Liz

Joel Pearson

unread,
Jul 14, 2014, 3:15:39 PM7/14/14
to rubyonra...@googlegroups.com
That's a very short error message. What did the rest of the error say?

--
Posted via http://www.ruby-forum.com/.

Liz Huang

unread,
Jul 14, 2014, 3:49:51 PM7/14/14
to rubyonra...@googlegroups.com


I don't see anything else though, let me copy the whole page:

LoadError in SamplesizeController#compute

cannot load such file -- dl

Extracted source (around line #14):
12
13
14
15
16
17
          
def compute
require 'dl'
require 'pathname'
# if ( session[:sigma_sq] <= 0.0 )

Rails.root: /Library/WebServer/smart

Application Trace | Framework Trace | Full Trace
app/controllers/samplesize_controller.rb:14:in `compute'
This error occurred while loading the following files:
   dl

Request

Parameters:

None

Matt Jones

unread,
Jul 15, 2014, 2:46:35 PM7/15/14
to rubyonra...@googlegroups.com


On Monday, 14 July 2014 15:49:51 UTC-4, Liz Huang wrote:


I don't see anything else though, let me copy the whole page:

LoadError in SamplesizeController#compute

cannot load such file -- dl

Extracted source (around line #14):
12
13
14
15
16
17
          
def compute
require 'dl'
require 'pathname'
# if ( session[:sigma_sq] <= 0.0 )

Rails.root: /Library/WebServer/smart

Application Trace | Framework Trace | Full Trace
app/controllers/samplesize_controller.rb:14:in `compute'
This error occurred while loading the following files:
   dl


DL was deprecated in Ruby 2.0 and removed in 2.1 in favor of Fiddle. Fiddle docs:


--Matt Jones 

Liz Huang

unread,
Jul 15, 2014, 3:55:54 PM7/15/14
to rubyonra...@googlegroups.com


Thanks! I will check fiddle out and post if I have any questions. It can call .dylib?

Liz

Liz Huang

unread,
Aug 4, 2014, 11:01:33 AM8/4/14
to rubyonra...@googlegroups.com

Dear Matt:

I have tried fiddle, but couldn't make it to import functions in .dylib (Fortran dll generated by intel
fortran compiler) that I could use DL to import successfully before.  Any suggestions?

Thanks!
Liz

Liz Huang

unread,
Aug 4, 2014, 1:19:07 PM8/4/14
to rubyonra...@googlegroups.com


Does fiddle work in Mac? I saw some comment that it doesn't work in all platforms.

Liying
Reply all
Reply to author
Forward
0 new messages