【问题标题】:wxHaskell on OS XOS X 上的 wxHaskell
【发布时间】:2011-03-03 01:04:31
【问题描述】:

我想在 OS X(Snow Leopard、MacBook Pro)上使用 wxHaskell。我能够成功安装库和下面的脚本:

module Main 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]

确实会按照指定的方式显示一个带有单个按钮的窗口。然而,当我点击按钮时,什么都没有发生——我什至没有看到按钮变成蓝色的视觉反应,表明它已被按下(哈哈,没有双关语)。

我听说你必须在 wxHaskell 二进制文件上运行一个名为“macosx-app”的包才能让它们运行,但我在任何地方都找不到。它不在我的机器上或(据我所知)在 WX 或 wxHaskell 发行版中。

有人知道我需要做什么才能让它工作吗?

【问题讨论】:

标签: macos haskell wxwidgets


【解决方案1】:

source releasebin 目录中包含一个名为macosx-app-template 的文件。 configure 脚本的以下部分使用此文件来创建 macosx-app

cat > config/macosx-app-temp << EOF
#!/bin/sh
rezcomp="$wxinstallrezcomp"
rezfile="$wxinstallrezfile"

EOF
cat config/macosx-app-temp bin/macosx-app-template > config/macosx-app
rm -f config/macosx-app-temp
chmod a+x config/macosx-app

如果您已经安装了 wxHaskell 并且没有使用 configure 脚​​本,您可能只需重复这些步骤,即,将 macosx-app-template 复制到 macosx-app,使其可执行,然后在顶部:

#!/bin/sh

libdir=""

wxrezcomp="`wx-config --rezflags`"
wxrezfile=""
if test "$wxrezcomp"; then
  for word in $wxrezcomp; do
    temp="`echo $word | grep '[^_]*_mac-[^r]*r'`"
    if test "$temp"; then
      wxrezfile="$temp"
    fi
  done
fi

if test "$wxrezfile"; then
  wxrezdir="`echo $wxrezfile | sed -e 's|\(.*\)/libwx_mac.*|\1|'`"
  wxinstallrezcomp="`echo \"${wxrezcomp}\" | sed -e \"s|${wxrezdir}|${libdir}|g\"`"
  wxinstallrezfile="`echo \"${wxrezfile}\" | sed -e \"s|${wxrezdir}|${libdir}|g\"`"
fi

rezcomp="$wxinstallrezcomp"
rezfile="$wxinstallrezfile"

请注意,您需要更改libdir="" 以指定安装wxHaskell 库文件的目录,如果wx-config 不在您的路径中,您也需要更改该行。

【讨论】:

  • 现在看来,wxHaskell(0.12.1.6)是通过Cabal分发的; Cabal 从 Hackage 下载的 tar.gz 文件缺少 bin/ 子目录条目,而且,不用说,macosx-app-template。我们这些 Mac 书呆子还有希望吗?
【解决方案2】:

我使用 cabal 安装了 wxhaskell,并阅读了其他说明,我按照以下步骤进行操作,以使 macosx-app 正常工作:

  1. 我从以下位置下载 wxhaskell 源 http://haskell.org/haskellwiki/WxHaskell/Download

  2. 我解压下载的文件:

    wxhaskell-src-XXX.zip

    其中 XXX 是版本号。

  3. 我在解压缩的目录中运行配置。 这会从模板创建文件 config/macosx-app

    .configure

  4. 我使用 sudo 将文件复制到 bin 目录 /usr/local/bin

    sudo cp config/macosx-app /usr/local/bin

  5. 我删除了包含源文件的目录

这对我有用!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-27
    • 2010-10-03
    • 2014-01-31
    • 1970-01-01
    • 2011-09-10
    • 2015-12-24
    相关资源
    最近更新 更多