我想使用一个打包程序http://hackage.haskell.org/package/clipper来检测复杂多边形的交集。这是C ++程序包的FFI。运行就可以了
cabal build --with-gcc=/usr/bin/g++
但不是这样。有什么方法可以将该gcc选项放入cabal文件中,或者以其他方式获取我的堆栈项目以使用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行崩溃,因此为了打印标志,我需要更改顺序。
试试下面这个简单的自定义Setup.hs文件:
import Distribution.Simple
import System.Environment
main = do
args <- getArgs
defaultMainArgs $ ["--with-gcc=c++"] ++ args
原始答案
一些想法:
(1)创建一个名为的包装器脚本gcc
,它调用g++
。将脚本放在PATH的早期,以便运行gcc
将运行脚本而不是real gcc
。也许只有在构建Clipper包时,才具有此包装器脚本。
(2)编写一个自定义的Setup.hs。
build-type
将clipper.cabal文件中的字段修改为Custom
而不是Simple
将Setup.hs文件替换为:
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'
注意:不需要导入Text.Show.Pretty,因此,如果未安装它,则可以将其删除,并可以调用ppShow。
上面的Setup.hs应该与用调用cabal具有相同的效果--with-gcc=g++
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句