Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redistribute wxHaskell apps?

I am using ghc 7.6.3. I installed wxHaskell from here: https://github.com/wxHaskell/wxHaskell

It worked, the sample programs compile and the run successfully.

The only problem now is that I want to distribute a wxHaskell application on mac OS X. I tried using macosx-app and cabal-macosx (https://github.com/michaelt/cabal-macosx) to make an "app" file. It runs fine on my machine, but it fails to run on another computer. I get the following error:

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

I am using OS X 10.8.4 (Mountain Lion), but I would be also interested in compiling apps on Windows and redistribute them too.

What would be the best way to redistribute wxHaskell apps?

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 <[email protected]>
Author:                 Andy Gimblett <[email protected]>
Maintainer:             Andy Gimblett <[email protected]>
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

Here are the dylib files inside the generated package:

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
like image 402
esato1981 Avatar asked Nov 03 '22 17:11

esato1981


1 Answers

The last redistributable I made in Windows with wxHaskell needed the files

  • mingwm10.dll and
  • wxmws28u_gcc.dll

to be in the same folder as the .exe (not just somewhere on my path).

This was using a previous version of wxHaskell, which compiled against a previous version of wxWidgits itself, so presumably you'd need the wx dll to have 29 in it rather than 28.

I compiled with static linking too:

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

the -optl-mwindows gets rid of the command prompt window which would otherwise appear alongside your app.

like image 143
AndrewC Avatar answered Nov 15 '22 07:11

AndrewC