加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

common-lisp – 如何在defsystem中设置C编译器?

发布时间:2020-12-16 07:06:30 所属栏目:百科 来源:网络整理
导读:我正在尝试使用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
我正在尝试使用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_64/mp??i.h标头 – 所以也许我需要设置包含路径而不是编译器?如果是这样,怎么样?

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

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

在defsystem之前

编辑:哎呀,这是生成坏的cffi包括:(看起来像这样:

#include </usr/include/mpi/mpi.h>

代替:

#include "mpi.h"

有什么方法可以做些什么吗?

应用大量的hackery和技巧我可以让它工作.看来,库的路径是在代码本身中设置的,所以我不得不这样做

(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),并将其提交到上游.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读