deech / CPlusPlusBindings

Test project for binding Haskell to a C++ library.
MIT License
6 stars 2 forks source link

Simplified bindings #2

Closed crockeea closed 8 years ago

crockeea commented 8 years ago

Inspired by the monumental effort required to get this example to link, I searched for (and found) a better path. My findings are summarized here.

I updated your repo to reflect this simpler method. In paticular, this method does not require a custom build-type or Setup.hs, it does not require c2hs, it does not require makefiles at all, and it does not require any sort of linking options on the executable.

deech commented 8 years ago

Wow, this is great! Thanks for putting in the time.

deech commented 8 years ago

It works fine on my Debian VM, but on my Ubuntu machine I get:

deech@deech-ThinkPad-W550s:~/Haskell/CPlusPlusBindings$ cabal build
./CPlusPlusBinding.cabal has been changed. Re-configuring with most recently
used options. If this fails, please run configure manually.
Resolving dependencies...
Configuring CPlusPlusBinding-0.1.0.0...
Building CPlusPlusBinding-0.1.0.0...
Preprocessing library CPlusPlusBinding-0.1.0.0...

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead
In-place registering CPlusPlusBinding-0.1.0.0...
cabal: '/usr/local/bin/ghc-pkg' exited with an error:
CPlusPlusBinding-0.1.0.0: Warning: haddock-interfaces:
/home/deech/Haskell/CPlusPlusBindings/dist/doc/html/CPlusPlusBinding/CPlusPlusBinding.haddock
doesn't exist or isn't a file
CPlusPlusBinding-0.1.0.0: Warning: haddock-html:
/home/deech/Haskell/CPlusPlusBindings/dist/doc/html/CPlusPlusBinding doesn't
exist or isn't a directory
CPlusPlusBinding-0.1.0.0: installed package info from too old version of Cabal
(key field does not match id field)
deech@deech-ThinkPad-W550s:~/Haskell/CPlusPlusBindings$ cabal clean
cleaning...
deech@deech-ThinkPad-W550s:~/Haskell/CPlusPlusBindings$ cabal build
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring CPlusPlusBinding-0.1.0.0...
Building CPlusPlusBinding-0.1.0.0...
Preprocessing library CPlusPlusBinding-0.1.0.0...

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead
[1 of 1] Compiling Binding          ( src/Binding.hs, dist/build/Binding.o )

on the commandline: warning:
    -this-package-key is deprecated: Use -this-unit-id instead
In-place registering CPlusPlusBinding-0.1.0.0...
cabal: '/usr/local/bin/ghc-pkg' exited with an error:
CPlusPlusBinding-0.1.0.0: Warning: haddock-interfaces:
/home/deech/Haskell/CPlusPlusBindings/dist/doc/html/CPlusPlusBinding/CPlusPlusBinding.haddock
doesn't exist or isn't a file
CPlusPlusBinding-0.1.0.0: Warning: haddock-html:
/home/deech/Haskell/CPlusPlusBindings/dist/doc/html/CPlusPlusBinding doesn't
exist or isn't a directory
CPlusPlusBinding-0.1.0.0: installed package info from too old version of Cabal
(key field does not match id field)
crockeea commented 8 years ago

That looks like some generic cabal issues. -this-package-key is deprecated: use -this-unit-id is suspicious, and the other warnings are about haddock. What version of GHC and cabal are you using on Ubuntu?

deech commented 8 years ago

Yep, I had an old version of Cabal, upgraded to 1.24 and all is well. Thanks!

crockeea commented 8 years ago

It'd be nice to know what version of cabal you actually had so I have an idea of a lower bound of the version that works.

deech commented 8 years ago

The problem was that I had Cabal 1.22 and GHC 8.0.1. The minimum version supported by GHC 8 is 1.24. It would probably have worked if I was using GHC 7.10.3.

crockeea commented 8 years ago

Useful to know, thanks!