从Hackage下载Haskell绑定到c-library时指定gcc编译器标志

时间:2017-08-26 00:02:32

标签: haskell gcc cabal hackage

我想在Hackage上为Minisat解算器安装绑定,以解决可用的问题here

当我在Linux工作站的命令行上尝试cabal install minisat-solver时,我得到了以下输出

user@home: $ cabal install minisat-solver
Resolving dependencies...
Configuring minisat-solver-0.1...
Building minisat-solver-0.1...
Failed to install minisat-solver-0.1
Build log ( /home/gaurish/.cabal/logs/minisat-solver-0.1.log ):
cabal: Entering directory '/tmp/cabal-tmp-6317/minisat-solver-0.1'
Configuring minisat-solver-0.1...
Building minisat-solver-0.1...
Preprocessing library minisat-solver-0.1...
[1 of 7] Compiling SAT.MiniSat.Literals ( SAT/MiniSat/Literals.hs, dist/build/SAT/MiniSat/Literals.o )
[2 of 7] Compiling SAT.MiniSat.LowLevel ( SAT/MiniSat/LowLevel.hs, dist/build/SAT/MiniSat/LowLevel.o )
[3 of 7] Compiling SAT.MiniSat.Monadic ( SAT/MiniSat/Monadic.hs, dist/build/SAT/MiniSat/Monadic.o )
[4 of 7] Compiling SAT.MiniSat.Functional ( SAT/MiniSat/Functional.hs, dist/build/SAT/MiniSat/Functional.o )
[5 of 7] Compiling SAT.MiniSat.Variable ( SAT/MiniSat/Variable.hs, dist/build/SAT/MiniSat/Variable.o )
[6 of 7] Compiling SAT.MiniSat.Formula ( SAT/MiniSat/Formula.hs, dist/build/SAT/MiniSat/Formula.o )
[7 of 7] Compiling SAT.MiniSat      ( SAT/MiniSat.hs, dist/build/SAT/MiniSat.o )
c-sources/solver.c: In function ‘solver_simplification’:

c-sources/solver.c:901:3:
     error: ‘for’ loop initial declarations are only allowed in C99 mode
       for (int i = solver_dlevel(s); i >= 0; i--) {
       ^

c-sources/solver.c:901:3:
     note: use option -std=c99 or -std=gnu99 to compile your code

c-sources/solver.c:907:3:
     error: ‘for’ loop initial declarations are only allowed in C99 mode
       for (int c = s->qtail - 1; c >= 0; c--) {
       ^

显然,我需要告诉cabal在编译嵌入式C源时告诉gcc使用ansi-c99模式。换句话说,将-std = c99传递给gcc编译器。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

--gcc-option可能会做到这一点。

它也在here中找到--prog-option,其中prog是任何已知的cabal程序(例如gcc)

另一种选择是自己下载软件包,然后修改其构建配置。