Setting up an emacs EDE-project with libraries

若如初见. 提交于 2019-12-07 04:39:07

问题


I already searched the emacs documentation, the cedet website and here on SO in vain. If my question is already been answered, fell free to (point out to an existing answer and) close it.

I'm trying to familiarize myself with EDE-projects in emacs. So far I can set up a simple project with one or more files.

Now I'd like to separate a part of my code and pack it into a library. Basically I'm trying to achieve the same thing I get with the following hand-written naive 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

Here I have a library consisting of "lib/matrix.h" and "lib/matrix.cpp" (it's a toy implementation of a matrix type) and a file "num.cpp" that uses matrix.

I don't know how to tell emacs to compile matrix properly. So far I got the following EDE-project, but of course it doesn't compile.

;; 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
  )

回答1:


So,

i think I solved it. I'm answering the question myself, in case someone stumbles on the same difficulties.

Basically I needed to define a subproject in the directory "lib/" which compiles and archives the library.

I now have the following files

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

the config-file lib/Project.ede is the subproject responsible for the library and it looks like this:

;; 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")))
    )
   )
  )

The main file ./Project.ede looks like this:

;; 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")
    )
   )
  )


来源:https://stackoverflow.com/questions/6480144/setting-up-an-emacs-ede-project-with-libraries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!