簡體   English   中英

無法運行在GHCI中運行的wxHaskell程序

[英]Unable to runhaskell my wxHaskell program that works in GHCI

我試圖在Windows 7上創建一個HelloWorld.exe,它演示了我在網上找到的一個非常簡單的wxHaskell程序。 代碼如下:

module HelloWorldWX where
import Graphics.UI.WX

main :: IO ()
main
  = start hello

hello :: IO ()
hello = do
       f    <- frame    [text := "Hello!"]
       quit <- button f [text := "Quit", on command := close f]
       set f [layout := widget quit]

在一個名為HelloWorldWX.hs的文件中。 我下載了wxHaskell的二進制發行版(wxInstall-Achelanne-64-0.1)。 在運行Install.bat后,我注意到它使用Cabal來設置一個新的軟件包位置,它安裝了wx-0.92.0.1及其所有依賴項。 第一次運行它失敗了一些非特定的原因。 我運行了ghc-pkg list ,發現所有的軟件包都列在新的cabal軟件包位置。 我決定取消注冊所有包,然后再試一次。 這是第二次成功並促使我在我的搜索路徑中包含以下目錄:

C:\\用戶\\下載\\ wxInstall-Achelanne-64-0.1 \\ DLL文件:C:\\用戶\\下載\\ wxInstall-Achelanne-64-0.1 \\ wxWidgets的\\ LIB \\ gcc_dll

此時,當我將HelloWorldWX.hs加載到GHCI並運行main時,我得到了像我期望的Quit按鈕的窗口框架。

然后我將.hs文件編譯成.o文件。 然后,我嘗試使用以下命令創建可執行文件:

ghc -v -o HelloWorldWX HelloWorldWX.o

Glasgow Haskell Compiler, Version 7.10.3, stage 2 booted by GHC version 7.10.2
Using binary package database: C:\Users\...\Haskell Platform\7.10.3\lib\pack
age.conf.d\package.cache
Using binary package database: C:\Users\...\AppData\Roaming\ghc\x86_64-mingw
32-7.10.3\package.conf.d\package.cache
wired-in package ghc-prim mapped to ghc-prim-0.4.0.0-428c198583a031a3ea42dd32ae6
f9bab
wired-in package integer-gmp mapped to integer-gmp-1.0.0.0-3c8c40657a9870f5c33be
17496806d8d
wired-in package base mapped to base-4.8.2.0-14035a44a8b95c6832da6dae1420f59e
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.10.0.0-bcb07fec12
f32563bb45d7fb009640b1
wired-in package ghc mapped to ghc-7.10.3-7a0d3c701e4b1d1f2c3f3bd2deae9bed
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
Created temporary directory: C:\Users\...\AppData\Local\Temp\1\ghc13152_0
*** C Compiler:
"C:\Users\...\Haskell Platform\7.10.3\lib/../mingw/bin/gcc.exe" "-fno-stack-
protector" "-DTABLES_NEXT_TO_CODE" "-c" "C:\Users\...\AppData\Local\Temp\1\g
hc13152_0\ghc_1.c" "-o" "C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_2.
o" "-IC:\Users\...\Haskell Platform\7.10.3\lib/include"
*** Windres:
"C:\Users\...\Haskell Platform\7.10.3\lib/../mingw/bin/windres.exe" "--prepr
ocessor=\"C:\Users\...\Haskell Platform\7.10.3\lib/../mingw/bin/gcc.exe\" \"
-fno-stack-protector\" \"-DTABLES_NEXT_TO_CODE\" \"-E\" \"-xc\" \"-DRC_INVOKED\"
" "--use-temp-file" "--input=C:\Users\...\AppData\Local\Temp\1\ghc13152_0\gh
c_4.rc" "--output=C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_5.o" "--o
utput-format=coff"
*** Linker:
"C:\Users\...\Haskell Platform\7.10.3\lib/../mingw/bin/gcc.exe" "-fno-stack-
protector" "-DTABLES_NEXT_TO_CODE" "-Wl,--hash-size=31" "-Wl,--reduce-memory-ove
rheads" "-Xlinker" "--stack=0x800000,0x800000" "-static-libgcc" "-o" "HelloWorld
WX.exe" "-Wl,--enable-auto-import" "HelloWorldWX.o" "C:\Users\...\AppData\Lo
cal\Temp\1\ghc13152_0\ghc_5.o" "-LC:\Users\...\Haskell Platform\7.10.3\lib\b
ase_HQfYBxpPvuw8OunzQu6JGM" "-LC:\Users\...\Haskell Platform\7.10.3\lib\inte
g_2aU3IZNMF9a7mQ0OzsZ0dS" "-LC:\Users\...\Haskell Platform\7.10.3\lib\ghcpr_
8TmvWUcS1U1IKHT0levwg3" "-LC:\Users\...\Haskell Platform\7.10.3\lib/rts" "C:
\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_2.o" "-Wl,-u,ghczmprim_GHCziT
ypes_Izh_static_info" "-Wl,-u,ghczmprim_GHCziTypes_Czh_static_info" "-Wl,-u,ghcz
mprim_GHCziTypes_Fzh_static_info" "-Wl,-u,ghczmprim_GHCziTypes_Dzh_static_info"
"-Wl,-u,base_GHCziPtr_Ptr_static_info" "-Wl,-u,ghczmprim_GHCziTypes_Wzh_static_i
nfo" "-Wl,-u,base_GHCziInt_I8zh_static_info" "-Wl,-u,base_GHCziInt_I16zh_static_
info" "-Wl,-u,base_GHCziInt_I32zh_static_info" "-Wl,-u,base_GHCziInt_I64zh_stati
c_info" "-Wl,-u,base_GHCziWord_W8zh_static_info" "-Wl,-u,base_GHCziWord_W16zh_st
atic_info" "-Wl,-u,base_GHCziWord_W32zh_static_info" "-Wl,-u,base_GHCziWord_W64z
h_static_info" "-Wl,-u,base_GHCziStable_StablePtr_static_info" "-Wl,-u,ghczmprim
_GHCziTypes_Izh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info" "-Wl,-u,ghc
zmprim_GHCziTypes_Fzh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info" "-Wl,
-u,base_GHCziPtr_Ptr_con_info" "-Wl,-u,base_GHCziPtr_FunPtr_con_info" "-Wl,-u,ba
se_GHCziStable_StablePtr_con_info" "-Wl,-u,ghczmprim_GHCziTypes_False_closure" "
-Wl,-u,ghczmprim_GHCziTypes_True_closure" "-Wl,-u,base_GHCziPack_unpackCString_c
losure" "-Wl,-u,base_GHCziIOziException_stackOverflow_closure" "-Wl,-u,base_GHCz
iIOziException_heapOverflow_closure" "-Wl,-u,base_ControlziExceptionziBase_nonTe
rmination_closure" "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_clo
sure" "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure" "-Wl,-u,
base_GHCziIOziException_allocationLimitExceeded_closure" "-Wl,-u,base_ControlziE
xceptionziBase_nestedAtomically_closure" "-Wl,-u,base_GHCziEventziThread_blocked
OnBadFD_closure" "-Wl,-u,base_GHCziWeak_runFinalizzerBatch_closure" "-Wl,-u,base
_GHCziTopHandler_flushStdHandles_closure" "-Wl,-u,base_GHCziTopHandler_runIO_clo
sure" "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" "-Wl,-u,base_GHCziConcziIO_
ensureIOManagerIsRunning_closure" "-Wl,-u,base_GHCziConcziIO_ioManagerCapabiliti
esChanged_closure" "-Wl,-u,base_GHCziConcziSync_runSparks_closure" "-Wl,-u,base_
GHCziConcziSignal_runHandlersPtr_closure" "-lHSbase-4.8.2.0-HQfYBxpPvuw8OunzQu6J
GM" "-lHSinteger-gmp-1.0.0.0-2aU3IZNMF9a7mQ0OzsZ0dS" "-lHSghc-prim-0.4.0.0-8TmvW
UcS1U1IKHT0levwg3" "-lHSrts" "-lCffi-6" "-lwsock32" "-luser32" "-lshell32" "-lm"
 "-lwsock32" "-lgdi32" "-lwinmm"
HelloWorldWX.o:fake:(.text+0x35): undefined reference to `wxcorzuLc8buVrXMQOAAoN
jm2eSy1_GraphicsziUIziWXCoreziLayout_zdfWidgetObject_closure'
HelloWorldWX.o:fake:(.text+0x91): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziAttributes_ZCze_con_info'
HelloWorldWX.o:fake:(.text+0x9a): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziTopLevelWindow_zdfFormObject_closure'
HelloWorldWX.o:fake:(.text+0xca): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziAttributes_set_closure'
HelloWorldWX.o:fake:(.text+0x11d): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziTopLevelWindow_zdfCloseableObject_closure'
HelloWorldWX.o:fake:(.text+0x15f): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziControls_zdfCommandingObject4_closure'
HelloWorldWX.o:fake:(.text+0x164): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziEvents_on_closure'
HelloWorldWX.o:fake:(.text+0x1ef): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziWindow_zdfTextualObject_closure'
HelloWorldWX.o:fake:(.text+0x27e): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziAttributes_ZCze_con_info'
HelloWorldWX.o:fake:(.text+0x2ce): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziAttributes_ZCze_con_info'
HelloWorldWX.o:fake:(.text+0x2ff): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziControls_button_closure'
HelloWorldWX.o:fake:(.text+0x427): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziWindow_zdfTextualObject_closure'
HelloWorldWX.o:fake:(.text+0x4b9): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziAttributes_ZCze_con_info'
HelloWorldWX.o:fake:(.text+0x4eb): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziFrame_frame_closure'
HelloWorldWX.o:fake:(.text+0x5da): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWX_start_closure'
HelloWorldWX.o:fake:(.text+0x1f8): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziClasses_text_info'
HelloWorldWX.o:fake:(.text+0x430): undefined reference to `wxzu6QQu5v1wfyA22ZZSl
eeGHgzz_GraphicsziUIziWXziClasses_text_info'
HelloWorldWX.o:fake:(.data+0x70): undefined reference to `wxcorzuLc8buVrXMQOAAoN
jm2eSy1_GraphicsziUIziWXCoreziLayout_zdfWidgetObject_closure'
HelloWorldWX.o:fake:(.data+0x78): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziAttributes_set_closure'
HelloWorldWX.o:fake:(.data+0x80): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziTopLevelWindow_zdfFormObject_closure'
HelloWorldWX.o:fake:(.data+0x88): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziTopLevelWindow_zdfCloseableObject_closure'
HelloWorldWX.o:fake:(.data+0x90): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziEvents_on_closure'
HelloWorldWX.o:fake:(.data+0x98): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziControls_zdfCommandingObject4_closure'
HelloWorldWX.o:fake:(.data+0xa8): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziWindow_zdfTextualObject_closure'
HelloWorldWX.o:fake:(.data+0xb0): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziControls_button_closure'
HelloWorldWX.o:fake:(.data+0xc8): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWXziFrame_frame_closure'
HelloWorldWX.o:fake:(.data+0xd8): undefined reference to `wxzu6QQu5v1wfyA22ZZSle
eGHgzz_GraphicsziUIziWX_start_closure'
C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_2.o:ghc_1.c:(.rdata$.refptr
.ZCMain_main_closure[.refptr.ZCMain_main_closure]+0x0): undefined reference to `
ZCMain_main_closure'
collect2.exe: error: ld returned 1 exit status
*** Deleting temp files:
Deleting: C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_6.rsp C:\Users\pp
77316\AppData\Local\Temp\1\ghc13152_0\ghc_5.o C:\Users\...\AppData\Local\Tem
p\1\ghc13152_0\ghc_4.rc C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_3.r
sp C:\Users\...\AppData\Local\Temp\1\ghc13152_0\ghc_2.o C:\Users\...\App
Data\Local\Temp\1\ghc13152_0\ghc_1.c
*** Deleting temp dirs:
Deleting: C:\Users\...\AppData\Local\Temp\1\ghc13152_0

我不確定為什么在找到這些參考文獻時遇到問題。

我嘗試執行然后

runhaskell HelloWorldWX.hs

並從ghc收到以下錯誤彈出:

在此輸入圖像描述

這里設置的詳細標志提供了一堆信息,這些信息並沒有真正詳細說明任何具體問題。

我正在從Windows Installer運行Haskell GHC 7.10.3完整包到本地用戶目錄。 我在這個工作站上沒有本地管理員權限,但我可以嘗試另一台機器。

有線索嗎? 我想第一次失敗的wxHaskell安裝已經損壞了某些東西,或者我遇到了特權問題。

我弄清楚問題是什么。 我忘了為GHC創建一個可執行文件,您需要明確指定要包含的Cabal包。 評論者Tomasz Lewowski部分正確。 gcc需要鏈接庫的-L選項,但是ghc應用程序通過使用-package選項智能地為給定的Cabal包添加所有必需的庫路徑。

完成這項工作的第二部分是我需要為main方法編譯指定-main-is的.o文件。 我寫了簡單的批處理文件並使其正常工作。

ghc -v -main-is HelloWorld.main HelloWorld.hs

ghc -v -o HelloWorld HelloWorld.o -package strict-0.3.2 -package wx-0.92.2.0 -package wxc-0.92.2.0 -package wxcore-0.92.2.0 -package wxdirect-0.92.2.0

這創建了Windows可執行文件很好,它就像一個魅力。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM