我正在尝试编写一个模拟Windows上击键的Haskell程序.我试图调用keybd_event和SendInput,但都没有编译.不过,我可以用解释器来运行程序.当我在winable.h中包含对SendInput的绑定时尝试构建程序时,我收到错误:
cabal install
...
[1 of 2] Compiling WindowsKeys ( dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.hs, dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.o )
[2 of 2] Compiling Main ( src\Main.hs, dist\build\WindowsKeys\WindowsKeys-tmp\Main.o )
Linking dist\build\WindowsKeys\WindowsKeys.exe ...
dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.o:fake:(.text+0x35d): undefined reference to `SendInput'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
WindowsKeys-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
详细错误发生在http://pastebin.com/trg21N0x,但它似乎不再包含任何线索.我尝试使用时遇到类似的错误keybd_event.我写的hsc文件包含以下标题:
#include "windows.h"
#include "winuser.h"
#include "winable.h"
Run Code Online (Sandbox Code Playgroud)
这是C绑定:
foreign import ccall unsafe "winable.h SendInput"
c_SendInput :: UINT
-> Ptr Input
-> CInt …Run Code Online (Sandbox Code Playgroud)