<![CDATA[Latest posts for the topic "Ruby-FFI: `ffi_libraries': no library specified (LoadError)"]]> /hvaonline/posts/list/24.html JForum - http://www.jforum.net Ruby-FFI: `ffi_libraries': no library specified (LoadError) http://copiousfreetime.rubyforge.org/tyrantmanager/ Các bước cài đặt đều OK: Code:
# gem list

*** LOCAL GEMS ***

arrayfields (4.7.4)
fattr (2.2.0)
ffi (0.6.3)
little-plugger (1.1.2)
logging (1.4.3)
loquacious (1.6.4)
main (4.4.0, 4.2.0)
rake (0.8.7)
rufus-tokyo (1.0.7)
tyrantmanager (1.6.0)
Tuy nhiên, khi mình chạy tyrantmanager thì gặp lỗi sau: Code:
# tyrantmanager setup /data/tyrant
/usr/lib64/ruby/gems/1.8/gems/loquacious-1.6.4/lib/loquacious/undefined.rb:87: warning: parenthesize argument(s) for future version
/usr/lib64/ruby/gems/1.8/gems/ffi-0.6.3/lib/ffi/library.rb:79:in `ffi_libraries': no library specified (LoadError)
	from /usr/lib64/ruby/gems/1.8/gems/ffi-0.6.3/lib/ffi/library.rb:106:in `attfunc'
	from /usr/lib64/ruby/gems/1.8/gems/rufus-tokyo-1.0.7/lib/rufus/tokyo/tyrant/lib.rb:59
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib64/ruby/gems/1.8/gems/rufus-tokyo-1.0.7/lib/rufus/tokyo/tyrant.rb:32
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/lib/tyrant_manager/tyrant_instance.rb:2
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/lib/tyrant_manager.rb:249
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib64/ruby/gems/1.8/gems/tyrantmanager-1.6.0/bin/tyrantmanager:9
	from /usr/bin/tyrantmanager:19:in `load'
	from /usr/bin/tyrantmanager:19
Nội dung file library.rb: Code:
30	module FFI
    31	  CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new
    32	
    33	  module Library
    34	    CURRENT_PROCESS = FFI::CURRENT_PROCESS
    35	    LIBC = FFI::Platform::LIBC
    36	
    37	    def self.extended(mod)
    38	      raise RuntimeError.new("must only be extended by module") unless mod.kind_of?(Module)
    39	    end
    40	
    41	    def ffi_lib(*names)
    42	
    43	      ffi_libs = names.map do |name|
    44	        if name == FFI::CURRENT_PROCESS
    45	          FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
    46	        else
    47	          libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact
    48	          lib = nil
    49	          errors = {}
    50	
    51	          libnames.each do |libname|
    52	            begin
    53	              lib = FFI::DynamicLibrary.open(libname, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
    54	              break if lib
    55	            rescue Exception => ex
    56	              errors[libname] = ex
    57	            end
    58	          end
    59	
    60	          if lib.nil?
    61	            raise LoadError.new(errors.values.join('. '))
    62	          end
    63	
    64	          # return the found lib
    65	          lib
    66	        end
    67	      end
    68	
    69	      @ffi_libs = ffi_libs
    70	    end
    71	
    72	
    73	    def ffi_convention(convention)
    74	      @ffi_convention = convention
    75	    end
    76	
    77	
    78	    def ffi_libraries
    79	      raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty?
    80	      @ffi_libs
    81	    end
Bạn nào rành Ruby giúp mình với. Cảm ơn mọi người. PS: disable mấy cái ": P", ": D", ... bị biến thành icons trong [ code] tag đi anh conmale ơi. Cái này bị lâu lắm rồi mà mãi không thấy anh sửa. Preview code mà nó cứ thè lưỡi ra cười làm em thấy khó chịu quá. ]]>
/hvaonline/posts/list/38531.html#236409 /hvaonline/posts/list/38531.html#236409 GMT