我正在尝试编写一个模拟
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
详细错误发生在http://pastebin.com/trg21N0x,但它似乎不再包含任何线索.我尝试使用keybd_event时遇到类似的错误.
我写的hsc文件包含以下标题:
#include "windows.h" #include "winuser.h" #include "winable.h"
这是C绑定:
foreign import ccall unsafe "winable.h sendinput" c_sendinput :: UINT -> Ptr Input -> CInt -> IO UINT
我假设我无法在winuser.h上调用sendinput,因为#if:
#if (_WIN32_WINNT >= 0x0403) WINUSERAPI UINT WINAPI sendinput(UINT,LPINPUT,int);
当我为_WIN32_WINNT添加绑定时,值为0x400.
我有Haskell平台的2012.4.0.0版.它附带了一个包含我所包含的标题的文件夹.我在计算机上找不到任何其他具有相同名称的标题.我使用的是Windows 7 Professional 6.1版.
谢谢!
这是WindowsKeys.cabal:
-- Initial WindowsKeys.cabal generated by cabal init. For further -- documentation,see http://haskell.org/cabal/users-guide/ name: WindowsKeys version: 0.1.0.0 build-type: Simple cabal-version: >=1.8 extra-source-files: windows.h,winuser.h,winable.h executable WindowsKeys main-is: Main.hs other-modules: WindowsKeys build-depends: base ==4.5.*,Win32 ==2.2.* hs-source-dirs: src build-tools: hsc2hs extra-libraries: user32 include-dirs: src
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。