MinGW上的Ruby FFI [英] Ruby FFI on MinGW
问题描述
我建立了一个(非常简单的)库,我可以从另一个C ++程序中调用它.
I built a (very simple) library, which I can call just fine from another C++ program.
但是当我尝试让Ruby FFI链接它时,它将无法工作.它给出FFI::NotFoundError
,表示找不到在DLL中导出的函数.
But it won't work when I try to get Ruby FFI to link it. It gives FFI::NotFoundError
, says it can't find the function exported in the DLL.
哪里出错了?使用g ++编译DLL时需要特殊处理吗?我只是用g++ -shared -o lib.dll libsrc.cpp
构建它.
Where might things have gone wrong? Do I need special treatment when I compile my DLL using g++? I am just building it with g++ -shared -o lib.dll libsrc.cpp
.
我对Ruby来说还很陌生,但是FFI的示例代码非常简单,而且我还有一些代码可以通过FFI从user32 DLL中完成一些相当复杂的事情.所以我知道它有效.
I am pretty new to Ruby, but sample code for FFI is very straightforward, and I also have code which does some pretty complex things from the user32 DLL thru FFI. So I know it works.
我可以考虑尝试的另一件事是使用Visual Studio编译我的代码,以期创建一个更加兼容"的DLL,但我想坚持使用GCC.
One more thing I can think of trying is compiling my code using visual studio in hopes of making a more "compatible" DLL, but I want to stick to GCC.
推荐答案
http://github.com /remogatto/ffi-inliner 可能会有所帮助.
请注意,如果以这种方式定义方法,则需要确保将您的方法称为stdcall.
Note that you need to make sure that you call your methods as stdcall if they are defined that way.
http://groups.google.com /group/ruby-ffi/browse_thread/thread/e2df39cdfe96a3c7?fwc = 1
您还可以将问题发布到ruby ffi google网上论坛.
You could also post your problem to the ruby ffi google group.
这篇关于MinGW上的Ruby FFI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!