Common lisp 如何在DEF系统中设置C编译器?

Common lisp 如何在DEF系统中设置C编译器?,common-lisp,cc,cffi,Common Lisp,Cc,Cffi,我正在尝试使用quicklisp加载cl-mpi系统。这是系统定义: (asdf:defsystem cl-mpi :description "Common Lisp bindings for the Message Passing Interface (MPI)" :author "Alex Fukunaga" :version "0.1.0" :license "MIT" :depends-on (:cffi :cffi-grovel) :co

我正在尝试使用
quicklisp
加载
cl-mpi
系统。这是系统定义:

(asdf:defsystem cl-mpi
    :description "Common Lisp bindings for the Message Passing Interface (MPI)"
    :author "Alex Fukunaga"
    :version "0.1.0"
    :license "MIT"
    :depends-on (:cffi :cffi-grovel)
    :components
    ((:file "packages")
     (:file "cl-mpi-configure" :depends-on ("packages"))
     (cffi-grovel:grovel-file "mpi-grovel" :depends-on ("packages" "cl-mpi-configure"))
     (:file "mpi" :depends-on ("packages"))))
这无法编译,因为它“不知道”
$CC
设置为什么。我需要将其设置为
mpicc
。我找到了代码,我认为它设置了:

(defun cc-compile-and-link (input-file output-file &key library)
  (let ((arglist
         `(,(or (getenv "CC") *cc*)
           ,@*cpu-word-size-flags*
           ,@*cc-flags*
           ;; add the cffi directory to the include path to make common.h visible
           ,(format nil "-I~A"
                    (directory-namestring
                     (truename
                      (asdf:system-definition-pathname :cffi-grovel))))
           ,@(when library *platform-library-flags*)
           "-o" ,(native-namestring output-file)
           ,(native-namestring input-file))))
    (when library
      ;; if it's a library that may be used, remove it
      ;; so we won't possibly be overwriting the code of any existing process
      (ignore-some-conditions (file-error)
        (delete-file output-file)))
    (apply #'invoke arglist)))
上述内容位于
asdf
包中。但是,我不明白如何更改
defsystem
来解释编译器

PS:错误看起来是这样的:

External process exited with code 1.
Command was: "cc" "-m64" "-I/home/wvxvw/quicklisp/dists/quicklisp/software/cffi_0.11.1/" 
"-o" "/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel" 
"/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel.c"

Output was:
/home/wvxvw/.cache/common-lisp/sbcl-1.1.2-1.fc18-linux-x64/home/wvxvw/quicklisp/local-projects/cl-mpi/mpi-grovel.c:6:34: 
fatal error: /usr/include/mpi/mpi.h: No such file or directory

compilation terminated.
格式化为可读性。编译器找不到标头,因为它不是正确的编译器(
mpicc
“知道”在哪里查找
mpi.h
标头,它不会在
/usr/include
中查找)


很抱歉给你带来了困惑。我可以将
$CC
设置为
mpicc
,但它仍然找不到
/usr/include/mpich-x86\u 64/mpi.h
头-所以我可能需要设置include路径而不是编译器?如果是,怎么做

这就是我如何将其设置为mpicc的方法:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :cffi-grovel)
  (setf cffi-grovel::*cc* "mpicc"))
defsystem

编辑:哎呀,是
cffi
生成了坏的include:(如下所示:

#include </usr/include/mpi/mpi.h>
有什么办法可以解决这个问题吗


应用大量的黑客和诡计,我可以让它工作。看起来库的路径是在代码中设置的,所以我不得不这样做

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :cffi-grovel)
  (setf cffi-grovel::*cc* "mpicc"
        mpi::*mpi-header-file* "/usr/include/mpich-x86_64/mpi.h"))
我还必须对我的系统做一些特殊的修改来编译整个程序


但是,如果可能的话,我希望这个问题能得到一般性的回答!例如,如何以一种通用且可接受的方式设置C编译器及其选项?

cl mpi包含一个名为“cl mpi configure.lisp”的文件。该文件看起来像是要更改为配置cl mpi,以便为您的系统使用正确的路径

具体而言,这一行:

(defvar *mpi-header-file* "/usr/include/mpi/mpi.h") ; this is where  ubuntu apt-get install puts mpi.h. 
定义mpi头文件的路径。您需要更改此行以在系统上使用mpi.h的路径。这有点烦人,因为您不需要使用本地版本,而需要直接从quicklisp下载


或者,您可以制作一个补丁来更智能地确定路径(例如使用
pkg config
),并向上游提交。

标签
编译器
应适用于有关编译器编程的问题或有关编译器详细内部工作的问题。不要使用
编译器
有关特定编译器的选项和设置的问题,请使用您感兴趣的编译器名称tead.在quicklisp或其他相关的BIT中安装一个包(可能在asdf land中)是否最好有一个通用的机制,它允许覆盖将这些东西视为某个路径前缀的位置?这似乎比逐个修补包要好。CFFI提供了使用pkg config的方法。但mpi包不使用在功能方面。
(defvar *mpi-header-file* "/usr/include/mpi/mpi.h") ; this is where  ubuntu apt-get install puts mpi.h.