Menu

#56 wxc build doesn't install libwxc.so

open-accepted
None
5
2014-07-01
2012-04-17
No

When I build and install wxc on Nixos, then the Setup.hs procedure fails to installs the generated libwxc.so DLL into the target directory. A complete build log is attached below that shows the output from running "./Setup configure -v3 && ./Setup build && ./Setup copy -v3".

Discussion

  • Peter Simons

    Peter Simons - 2012-04-17
     
  • Jeremy O\'Donoghue

    Hi Peter,

    I have looked at the log, and I think I understand the source of the problem, but not how to fix it, as I know nothing about NixOS beyond a 5 minute browse at the website just now and a good look at the build log. It looks as though it has a very different idea about where code is built and installed than other Unix systems, and we have designed and tested for a more typical scenario. That said - let's see if we can find a work-around.

    Because wxc is a shared library, we try to install it in a location where a typical Unix system stands a chance of finding it. We do this with a custom install hook (in Setup.hs), the relevant part of which is below:

    -- Copy shared library
    let bld_dir = buildDir local_bld_info

    ver = (pkgVersion . package) pkg_descr
    lib = fromJust (library pkg_descr)
    lib_bi = libBuildInfo lib
    custom_bi = customFieldsBI lib_bi
    dll_name = fromJust (lookup "x-dll-name" custom_bi)
    lib_name = sharedLibName ver dll_name

    inst_lib_dir = libdir $ absoluteInstallDirs pkg_descr local_bld_info NoCopyDest

    installOrdinaryFile (fromFlag (installVerbosity inst_flags)) (bld_dir </> lib_name) (inst_lib_dir </> lib_name)
    ldconfig inst_lib_dir

    What this does it to pick up the requested install directory from the package description and build info. In most cases this translates to somewhere under the ~/.cabal directory in the user's home directory. It sounds like this may not really exist in the same form on NixOS.

    If I read the Cabal documentation correctly, you may be able to work around this by using the --libdir=<directory> option when running Setup.hs configure. In any event, the install directory you want needs to be passed via the configuration if you want to install anywhere out of the ordinary.

    Unfortunately, it's not realistic for me to construct a NixOS build environment (I already maintain MacOS X, Windows 7, Ubuntu and FreeBSD, which is plenty, believe me), so I need to rely on you to try things out and see how they work.

     
  • Jeremy O\'Donoghue

    We don't really claim to support NixOS, but this may not be too difficult to fix if install directory is specified on the configure command line.

     
  • Jeremy O\'Donoghue

    • assigned_to: nobody --> jodonoghue
    • status: open --> open-accepted
     
  • Jeremy O\'Donoghue

    I also note that use you Setup copy. The recommended install procedure is:

    Setup configure && Setup build&& Setup install

    Without the Setup install stage, the install hook for libwxc.so never gets run.

     
  • Peter Simons

    Peter Simons - 2012-04-17

    To the best of my understanding, "./Setup copy" is supposed to perform the installation -- except for registering the built packages with the compiler. We perform that last step separately, i.e. by running "./Setup register". In my humble opinion, wxc's Setup.hs file should support the copy phase properly, i.e. it should copy the shared object it built.

     
  • Martin Øinæs Myrseth

    I ran into the same issue just now when trying to use wxHaskell with cabal sandboxes and linking to the wxHaskell-3.0 branch.

    cabal sandbox add-source <wxh-path>

    then

    cabal install --dependencies-only

    It stopped when trying to build wxcore because the shared library could not be found. It seemed to be an issue primarily on OSX, though.

    I took a stab at debugging this, and it seem like cabal install within a sandbox in fact uses cabal copy internally. The silly thing with cabal is that install hooks are not run for the copy command and copy hooks are not run for the install command. I found a mention of this somewhere, but I lost the link.

    Anyways, I've forked the github repo and quickly factored out the body of the myInstHook into a helper and added wrappers for the custom copy and install hooks, so that they do the same thing. It seems to do the trick for me. It would be great if somebody would have a look. I'll submit a pull request for it in any case...

    edit:

    Here's the github repo: https://github.com/myme/wxHaskell/commit/ab687a63806bf1bed890eb3e8acfdcec51c2f11d

     

    Last edit: Martin Øinæs Myrseth 2014-04-25
  • Michael LaCorte

    Michael LaCorte - 2014-06-17

    I also had this problem when trying to install the latest wxHaskell in a cabal-dev environment on Ubuntu 14.04. Martin's patch solved the issue for me.

     
  • Henk-Jan van Tuyl

    Martin's patch is now in the main wxHaskell repository: https://github.com/wxHaskell/wxHaskell

     

Log in to post a comment.