2011-06-25 41 views
5

我已經搜索了emacs文檔,cedet網站和SO這裏徒勞。如果我的問題已經得到解答,請隨意(指出現有答案)並關閉它。使用庫設置emacs EDE項目

我想讓自己熟悉emacs中的EDE項目。到目前爲止,我可以用一個或多個文件建立一個簡單的項目。

現在我想分離一部分代碼並將其打包到一個庫中。基本上我想要實現我用下面的手寫天真的Makefile得到同樣的事情:

matrix: 
    g++ -c -o lib/libmatrix.o lib/matrix.cpp -std=c++0x 
    ar crf lib/libmatrix.a lib/libmatrix.o 

num: 
    g++ num.cpp -Llib -Ilib -std=c++0x -o num -g 

這裏我有由「LIB/matrix.h」和「LIB/matrix.cpp」庫(這是一個矩陣類型的玩具實現)和一個使用矩陣的文件「num.cpp」。

我不知道如何告訴emacs正確編譯矩陣。到目前爲止,我得到了以下EDE項目,但它當然不能編譯。

;; Object Numbers 
;; EDE project file. 
(ede-proj-project "Numbers" 
    :name "Numbers" 
    :file "Project.ede" 
    :targets (list 
    (ede-proj-target-makefile-program "num" 
    :name "num" 
    :path "" 
    :source '("num.cpp") 
    :compiler 'ede-g++-compiler 
    :linker 'ede-g++-linker 
    :configuration-variables 'nil 
    :ldflags '("-std=c++0x" "-Llib" "-Ilib") 
    :ldlibs '("matrix") 
    ) 
    (ede-proj-target-makefile-archive "matrix" 
    :name "matrix" 
    :path "/lib" 
    :source '("matrix.cpp") 
    :compiler 'ede-g++-compiler 
    :linker 'ede-archive-linker 
    :configuration-variables 'nil 
    ) 
    ) 
    :configuration-variables 'nil 
) 

回答

3

所以,

我想我解決了這個問題。我自己也在回答這個問題,以防有人在同樣的困難中摔倒。

基本上我需要在編譯和歸檔庫的目錄「lib /」中定義一個子項目。

我現在有下列文件

include/ 
    matrix.h 
lib/ 
    Project.ede 
    matrix.cpp 
Project.ede 
num.cpp 

的配置文件中的lib/Project.ede負責圖書館的子項目,它看起來像這樣:

;; Object matrix 
;; EDE project file. 
(ede-proj-project "matrix" 
    :name "matrix" 
    :file "Project.ede" 
    :targets (list 
    (ede-proj-target-makefile-archive "matrix" 
    :name "matrix" 
    :path "" 
    :source '("matrix.cpp") 
    :configuration-variables '(("debug" ("CPPFLAGS" . "-I../include -std=c++0x -g")) ("release" ("CPPFLAGS" . "-I../include -std=c++0x"))) 
    ) 
    ) 
) 

主要文件。 /Project.ede看起來像這樣:

;; Object num 
;; EDE project file. 
(ede-proj-project "num" 
    :name "num" 
    :file "Project.ede" 
    :targets (list 
    (ede-proj-target-makefile-program "num" 
    :name "num" 
    :path "" 
    :source '("num.cpp") 
    :configuration-variables '(("debug" ("CPPFLAGS" . "-std=c++0x -Iinclude")) ("release" ("CPPFLAGS" . "-std=c++0x -Iinclude"))) 
    :ldflags '("-Llib") 
    :ldlibs '("matrix") 
    ) 
    ) 
)