2016-08-05 29 views
0

複雑なポリゴンの交差を検出するために使用するパッケージクリッパhttp://hackage.haskell.org/package/clipperがあります。これはC + +パッケージのFFIです。あなたはC++とスタック/カバールを使用したHaskellパッケージのコンパイル

cabal build --with-gcc=/usr/bin/g++

ではなく、それ以外を実行する場合は正常に動作します。そのgccオプションをカバールファイルに入れる方法はありますか?そうでなければg ++との依存関係を構築するために私のスタックプロジェクトを取得する方法はありますか?

何らかの理由が動作しないための$ PATHの設定:

% cabal build --with-gcc=g++ 
Building clipper-0.0.1... 
Preprocessing library clipper-0.0.1... 
[1 of 1] Compiling Algebra.Clipper (dist/build/Algebra/Clipper.hs, dist/build/Algebra/Clipper.o) 
In-place registering clipper-0.0.1... 

% PATH=$(pwd):$PATH gcc 
g++: fatal error: no input files 
compilation terminated. 

% PATH=$(pwd):$PATH cabal build 
Building clipper-0.0.1... 
Preprocessing library clipper-0.0.1... 
In file included from Clipper.hsc:27:0: 
cbits/clipper.hpp:29:18: fatal error: vector: Dosiero aŭ dosierujo ne ekzistas 
compilation terminated. 
compiling dist/build/Algebra/Clipper_hsc_make.c failed (exit code 1) 
command was: /usr/bin/gcc -c dist/build/Algebra/Clipper_hsc_make.c -o dist/build/Algebra/Clipper_hsc_make.o -fno-stack-protector -D__GLASGOW_HASKELL__=710 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -Idist/build/autogen -include dist/build/autogen/cabal_macros.h -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/base_GDytRqRVSUX7zckgKqJjgw/include -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/integ_2aU3IZNMF9a7mQ0OzsZ0dS/include -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/include -I/usr/local/haskell/ghc-7.10.2-x86_64/lib/ghc-7.10.2/include/ 

同様に、以下@ErikRによって提案されたようSetup.hsを変更する助けにはなりませんでした。

% runghc Setup.hs build 
"Hello, I am running" 
fomg 
BuildFlags 
    { buildProgramPaths = [] 
    , buildProgramArgs = [] 
    , buildDistPref = Flag "dist" 
    , buildVerbosity = Flag Normal 
    , buildNumJobs = NoFlag 
    , buildArgs = [] 
} 
fimg 
BuildFlags 
    { buildProgramPaths = [ ("gcc" , "/usr/bin/g++") ] 
    , buildProgramArgs = [] 
    , buildDistPref = Flag "dist" 
    , buildVerbosity = Flag Normal 
    , buildNumJobs = NoFlag 
    , buildArgs = [] 
    } 
Building clipper-0.0.1... 
Preprocessing library clipper-0.0.1... 
In file included from Clipper.hsc:27:0: 
(etc) 

これはbuildHook行でクラッシュすることに注意してください。フラグを出力するには、順序を変更する必要がありました。

import Distribution.Simple 
import System.Environment 

main = do 
    args <- getArgs 
    defaultMainArgs $ ["--with-gcc=c++"] ++ args 

オリジナル回答

いくつかのアイデア::

答えて

0

は、このシンプルなカスタムSetup.hsファイルを試してみてください

(1)g++を呼び出しgccと呼ばれるラッパースクリプトを作成します。スクリプトgccの代わりにgccを実行してスクリプトを実行するように、スクリプトをPATHの初期に置きます。おそらく、あなたはクリッパーパッケージを構築しているときにだけ、このラッパースクリプトを用意しています。

(2)カスタムSetup.hsを作成します。

  1. Setup.hsは、ファイルを置き換え代わりSimple
  2. Customするclipper.cabalファイルにbuild-typeフィールドを変更します。

    import Distribution.Simple 
    import Distribution.Simple.Setup 
    import Distribution.Simple.LocalBuildInfo 
    import Distribution.PackageDescription 
    import Text.Show.Pretty 
    
    main = do 
        let hooks = simpleUserHooks 
    
         myBuild :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO() 
         myBuild pkgd buildinfo uhooks flags = do 
         putStrLn $ ppShow flags 
         let flags' = flags { buildProgramPaths = [("gcc","g++")] ++ (buildProgramPaths flags) } 
         buildHook hooks pkgd buildinfo uhooks flags' 
         putStrLn $ ppShow flags' 
         hooks' = hooks { buildHook = myBuild } 
    
        defaultMainWithHooks hooks' 
    

注:テキストのインポートを.Show.Prettyは必要ではないので、あなたがそれをインストールしていなければppShowの呼び出しを取り除くことができます。

上記のSetup.hsは、cabalを--with-gcc=g++と呼ぶのと同じ効果があります。

+0

残念ながら、あなたの解決策は機能しませんでした。自分の経験を説明するために私の質問にいくつかのコメントを追加しました。 – Tristan

+0

ありがとうございます、より単純な提案が機能します。 – Tristan

関連する問題