在Ruby上调用dll(不是Windows API)
Calling Dlls on Ruby (not the Windows API)
我在一个Ruby环境中,我不能加载C扩展,只有纯Ruby代码。我不能使用RubyInline, FFI或Win32OLE,只有一种方法来加载外部代码:Win32API。但是我怎样才能编译出ruby需要的c++代码呢?我尝试使用这些代码,但引发了一个错误:
test.cpp
static int add(int a, int b) // I tried without static too
{
return a + b;
}
编译g++ --shared test.cpp -o test.dll
main.rb
Win32API.new('test.dll', 'add', 'II', 'I').call(1, 2) # => should return 3
错误消息RunTimeError
GetProcAddress: add or addA
版本:
Ruby 1.8.1
GCC 4.5.2 (tdm-1)
您需要使用. def文件。请看我对这个问题的回答
相关文章:
- <Windows>为什么 std::thread::native_handle 返回类型为"long long unsigned int"的值,而不是 void*(又名 HANDLE)?
- C++输出奇怪的字符而不是数字 (Windows)
- Linux 上的黑屏,但 Windows 上不是
- 将控制台应用程序直接输出到Visual Studio而不是外部Windows控制台中
- 我可以用C++/WinRT编写一个DLL,供windows桌面应用程序(而不是UWP)或Unity插件使用吗
- Windows 嵌入式标准不是有效的 win32 c++
- 为什么Qt资源被加载到Linux而不是Windows中?
- 如何强制Windows.h在Visual Studio中静态链接而不是动态链接?
- Clang 在Clion Windows中,如何使用mingw-w64而不是Windows VC运行
- C++应用程序仅在使用本地 Windows 调试器时运行,而不是哪个 exe 文件
- Windows VC++编译器允许一种奇怪的c样式转换方式(或者它可能不是转换??)
- 使用64位 自定义窗口形状(ETC平滑的角落不是矩形)在Windows中使用C 创建OpenGL窗口
- Windows HANDLE RAII 管理,如果返回布尔值而不是句柄怎么办?
- 什么是通用运行时组件 #ifdef 适用于Windows(UWP)而不是iOS
- Windows 控制台应用在新控制台而不是同一控制台中打开
- C# / C++应用程序在从Windows运行时崩溃,但不是从Visual Studio
- Windows 应用程序在以非管理员身份运行时看到旧版本的文件而不是当前版本
- 错误LNK2019:函数___tmainCRTStartup中引用了未解析的外部符号_main,但这次不是 Windows/控制台问题!
- 将Xaml文本框转换为double,但如何验证用户输入是double,而不是windows 8应用程序的c++中的字符串
- 在Ruby上调用dll(不是Windows API)