【问题标题】:How to redistribute wxHaskell apps?如何重新分发 wxHaskell 应用程序?
【发布时间】:2013-08-08 14:10:29
【问题描述】:

我正在使用 ghc 7.6.3。我从这里安装了 wxHaskell:https://github.com/wxHaskell/wxHaskell

成功了,示例程序编译并运行成功。

现在唯一的问题是我想在 mac OS X 上分发 wxHaskell 应用程序。我尝试使用 macosx-app 和 cabal-macosx (https://github.com/michaelt/cabal-macosx) 来制作“app”文件。它在我的机器上运行良好,但无法在另一台计算机上运行。我收到以下错误:

Dyld Error Message: Library not loaded: /Users/user/.cabal/lib/wxc-0.90.1.0/ghc-7.6.3/libwxc.dylib.

我使用的是 OS X 10.8.4 (Mountain Lion),但我也有兴趣在 Windows 上编译应用程序并重新分发它们。

重新分发 wxHaskell 应用程序的最佳方式是什么?

Setup.hs

-- Example Setup.hs for the wxHello app.

import Distribution.MacOSX
import Distribution.Simple

main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
         postBuild = appBundleBuildHook guiApps -- no-op if not MacOS X
       }

guiApps :: [MacApp]
guiApps = [MacApp "WxHello"
                  (Just "resources/WxHello.icns")
                  Nothing -- Build a default Info.plist for the icon.
                  [] -- No other resources.
                  [] -- No other binaries.
                  ChaseWithDefaults -- Try changing to ChaseWithDefaults
          ]

wxHello.cabal:

Name:                   wxHello
Version:                0.1.0
Stability:              Alpha
Synopsis:               wxWidgets `Hello World' example for cabal-macosx
Description:
    Example showing how to use cabal-macosx to build an application
    bundle for a simple `Hello World' program using the wxWidgets GUI
    toolkit.
Category:               Data
License:                BSD3
License-file:           LICENSE
Copyright:              Andy Gimblett <haskell@gimbo.org.uk>
Author:                 Andy Gimblett <haskell@gimbo.org.uk>
Maintainer:             Andy Gimblett <haskell@gimbo.org.uk>
Build-Type:             Custom
Cabal-Version:          >=1.6

Executable WxHello
  hs-source-dirs:       src
  Main-is:              Main.hs
  Build-Depends:        base >= 3 && < 5, cabal-macosx, wx
  ghc-options:          -fwarn-tabs -threaded -Wall

以下是生成包中的dylib文件:

WxHello.app $ find . | grep dylib
./Contents/Frameworks/Users/user/.cabal/lib/wxc-0.90.1.0/ghc-7.6.3/libwxc.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_baseu-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_baseu_net-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_baseu_xml-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_adv-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_aui-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_core-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_gl-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_html-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_propgrid-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_qa-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_ribbon-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_richtext-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_stc-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_webview-2.9.5.0.0.dylib
./Contents/Frameworks/Users/user/temp/wxWidgets-2.9.5/build-release/lib/libwx_osx_cocoau_xrc-2.9.5.0.0.dylib
./Contents/Frameworks/usr/lib/libc++abi.dylib
./Contents/Frameworks/usr/lib/libexpat.1.dylib
./Contents/Frameworks/usr/lib/libiconv.2.dylib
./Contents/Frameworks/usr/lib/libstdc++.6.dylib
./Contents/Frameworks/usr/lib/libz.1.dylib

【问题讨论】:

    标签: haskell wxhaskell


    【解决方案1】:

    我在 Windows 中使用 wxHaskell 制作的最后一个可再发行文件需要这些文件

    • mingwm10.dll
    • wxmws28u_gcc.dll

    与 .exe 位于 同一文件夹中(不仅仅是我路径上的某个位置)。

    这是使用之前版本的 wxHaskell,它针对之前版本的 wxWidgits 本身进行编译,因此您可能需要 wx dll 中包含 29 而不是 28。

    我也是用静态链接编译的:

    ghc -static -optl-static -optl-mwindows Main -o Project.exe
    

    -optl-mwindows 去掉了会出现在您的应用旁边的命令提示符窗口。

    【讨论】:

      【解决方案2】:

      包含 .cabal 和 Setup.hs 文件可能会有所帮助。

      从 cabal-macosx 上的文档来看,您似乎需要确保 Setup.hs 中的 MacApp 数据值获得适合 ChaseDeps 的模式(使用 ChaseWithDefaults而不是 DoNotChase) 以构建可再分发的应用程序包。

      如果您这样做了,但仍然遇到同样的错误,我会检查生成的应用程序包,看看是否有必要的库被复制到那里。您可能会找到足够的信息向 cabal-macosx 维护者提交错误。

      编辑

      根据您所包含的内容,设置看起来正确,并且似乎至少复制了库依赖项。我认为问题可能出在 cabal-macosx 包上。

      查看依赖修复代码的源代码,它看起来应该在构建包时打印了一堆"Updating &lt;library&gt;'s dependence on &lt;path&gt; to &lt;path&gt;" 行。你看到那些了吗?是否有任何行更新二进制文件本身?

      我对 OS X 链接过程不是很有经验,但我认为除非在复制库之后链接二进制文件,否则它也需要更新。您应该能够使用/usr/bin/otool -L &lt;filename&gt;/usr/bin/install_name_tool 手动修复安装过程可能遗漏的二进制文件中的路径。

      以下是这两个工具的手册页:

      https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

      https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/otool.1.html

      【讨论】:

        猜你喜欢
        • 2011-10-11
        • 1970-01-01
        • 2011-08-21
        • 1970-01-01
        • 2011-10-07
        • 1970-01-01
        • 2014-09-20
        • 1970-01-01
        • 2017-07-21
        相关资源
        最近更新 更多