Project

General

Profile

Actions

Bug #16117

closed

ruby2.6.3(x86) use fiddle faild to load dll in windows7

Added by whdukewu (Kewu DU) over 4 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [i386-mingw32]
[ruby-core:94482]

Description

I have a dll build by MinGW32 in windows7, in ruby2.2, I could use fiddle dlload this dll success, but in the same system, use 2.6.3 failed to dlload this dll, always report No such file or direcoty.

///////// Ruby2.2 success load the dll and call function in dll /////////

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>C:\TestTools\impeller\lib\Ruby\bin\ruby -v
ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32]

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>C:\TestTools\impeller\lib\Ruby\bin\ruby testmml_win.rb F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\
Demo for invoke C# code from ruby...
F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\
F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\libhostprotocol.dll
Load CoreCLR from F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\ success
CoreCLR Started success.

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>

///////// Ruby2.6.3 success load the dll and call function in dll /////////

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [i386-mingw32]

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>ruby testmml_win.rb F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x
86\publish\
Demo for invoke C# code from ruby...
F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\
F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\libhostprotocol.dll
Traceback (most recent call last):
        7: from testmml_win.rb:24:in `<main>'
        6: from testmml_win.rb:26:in `<module:ProtocolTest>'
        5: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:77:in `dlload'
        4: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:77:in `collect'
        3: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:87:in `block in dlload'
        2: from C:/Ruby26/lib/ruby/2.6.0/fiddle.rb:47:in `dlopen'
        1: from C:/Ruby26/lib/ruby/2.6.0/fiddle.rb:47:in `new'
C:/Ruby26/lib/ruby/2.6.0/fiddle.rb:47:in `initialize': No such file or directory (Fiddle::DLError)
        5: from testmml_win.rb:24:in `<main>'
        4: from testmml_win.rb:26:in `<module:ProtocolTest>'
        3: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:77:in `dlload'
        2: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:77:in `collect'
        1: from C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:86:in `block in dlload'
C:/Ruby26/lib/ruby/2.6.0/fiddle/import.rb:89:in `rescue in block in dlload': can't load F:\TOOLCODE\coreclr_win\Navigator2-linux\src\CSharpAdapter\CSharpAdapter\bin\Release\netcoreapp3.0\win-x86\publish\libhostprotocol.dll (Fiddle::DLError)

F:\TOOLCODE\coreclr_win\Navigator2-linux\src\ProtocolHost\HostTest\ruby\Mml>

the same testmml_win.rb in the same system, ruby2.2 works, ruby2.6.3 failed!

below is the test ruby code:

require 'fiddle'
require 'fiddle/import'


if ARGV.length < 1
   puts "Missing libPath argument..."
   puts "Usage:  ruby HostTest2.rb libPath"
   puts "Sample: ruby HostTest2.rb /home/ProtocolAdapter/output"
   exit
end   

puts "Demo for invoke C# code from ruby..."


String libPath = ARGV[0]
if libPath[libPath.length - 1] != '\\'
    libPath = libPath + '\\'
end
puts libPath
$libCoreCLR_so_path = libPath + "libhostprotocol.dll"
puts $libCoreCLR_so_path


module ProtocolTest
    extend Fiddle::Importer
    dlload $libCoreCLR_so_path
	
    extern 'void Init(const char* libPath)'
end

ProtocolTest.Init(libPath);

Updated by whdukewu (Kewu DU) over 4 years ago

testmml_win.rb code:

require 'fiddle'
require 'fiddle/import'


if ARGV.length < 1
   puts "Missing libPath argument..."
   puts "Usage:  ruby HostTest2.rb libPath"
   puts "Sample: ruby HostTest2.rb /home/ProtocolAdapter/output"
   exit
end   

puts "Demo for invoke C# code from ruby..."


String libPath = ARGV[0]
if libPath[libPath.length - 1] != '\\'
    libPath = libPath + '\\'
end
puts libPath
$libCoreCLR_so_path = libPath + "libhostprotocol.dll"
puts $libCoreCLR_so_path


module ProtocolTest
    extend Fiddle::Importer
    dlload $libCoreCLR_so_path
	
    extern 'void Init(const char* libPath)'
end

ProtocolTest.Init(libPath);
Actions #2

Updated by kou (Kouhei Sutou) over 4 years ago

  • Description updated (diff)

Updated by whdukewu (Kewu DU) over 4 years ago

Problem solved:
the dll i used compiled by MinGW, the dll need libstdc++-6.dll, after I add -static-libgcc -static-libstdc++ compile flag to the dll, problem solved!

Actions #4

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Status changed from Open to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0