How to create an EDE project for C ++

I am trying to create an EDE project for C ++ (emacs24 + built-in CEDET) and I am starting to despair because I cannot find the way that I want make files to be generated. I am relatively new to Emacs. I will try to describe what I am doing:

I have a toy project defined like this:

main.cpp other/ Utils.cpp Utils.h CGrabBuffer.cpp CGrabBuffer.h 

main.cpp contains both .h inside the "other /" directory. Here are the steps I'm following to set up an EDE project with this simple directory setup:

  • Open main.cpp in emacs and do Mx ede-new ; type: Make ; name: main-proj .
  • Open one of the files in a "different" directory and make Mx ede-new ; type: Make ; name: aux-proj .
  • Now it's time to create the targets (in this case, in my opinion, three):
    • In the buffer main.cpp: Mx ede-new-target ; name: main ; type: program . When prompted, I will add main.cpp to this goal.
    • I repeat the same for two other purposes (Utils with Utils.cpp and Utils.h and CGrabBuffer, which have CGrabBuffer.cpp and CGrabBuffer.h). Here I find the first problem. What type of two goals should be? I want them to generate .o files.
  • Once this is done, I type Mx ede-customize-current-target for all three goals and add some included paths, some libraries, etc.
  • After that, if I call Mx ede-compile-project , it does not compile because:
    • First tries to compile main.cpp; I don't know how to specify (using EDE) that both Utils.o and CGrabBuffer.o are needed before trying to build main.cpp.
    • If I manually change the order (editing the Makefile), it will not be able to link main.cpp because it cannot find Utils.o and CGrabBuffer.o.

As you can see, I am in the middle of a big mess. Perhaps I don’t even understand what “target” means in EDE. I also read about the existence of an ede-cpp-root project, which must be specified inside the .emacs file. I have not tried, because what I think is just help in semantics. It does not generate a makefile, does it? Can I (or do I need) an EDE project created using Project.el and the same thing using ede-cpp-root-project for semantics? Or is it redundant?

Sorry if I misunderstood many things, but I am very confused and not familiar with emacs, which makes the situation worse. Thank you for your patience!

EDIT: with some of the mastering and answers I received, I was able to figure out many things, so thank you very much. What I still don't understand is the use of the ede-cpp-root project, which should be specified inside the .emacs file. Is it easy for C ++ semantics? Is it redundant to have a project with Project.el as well as elisp strings in .emacs?

+7
source share
2 answers

EDE is designed to handle many different projects, usually the type in which the build system was written outside of Emacs in some other tool.

The type of EDE project that the Makefile creates for you can do a lot of things, but you need to have some basic understanding of build systems to be useful, and you really need to set up projects to get any of the complexity involved.

I recently added a section to the EDE manual to help with the basic project settings that automatically generate Automake files. You can read the tutorial here:

http://www.randomsample.de/cedetdocs/ede/ede/Quick-Start.html

The same steps will apply to projects that use Make instead, but for project-based projects, there are often problems with shared libraries due to the added complexity.

Mike's answer is not bad, but I think you can just add .h files to the same target as your .cpp sources. He will track them separately.

Another useful trick is to use the entire project compilation code (Cc. C), which uses C capital whenever you change something big. This will regenerate the Make files, repeat any necessary Automake functions and start from the top.

EDIT . You only need one EDE project for the project project area. The ede-cpp-root project is useful when another type of automatic project does not work. This is when you create this in your .emacs file so that other tools that need a project definition, such as semantic smart completion and tag search, will work.

+7
source

Well, I think I actually understood, this time, but it's ugly. Utils.cpp and CGrabBuffer.cpp should not get their own individual goals, because there does not seem to be an appropriate target type. Instead, you will need to create an archive or library that will automatically compile Utils.cpp and CGrabBuffer.cpp for you. Below I assume you want a static one, but it is easy to change it.

[For those who are not familiar with archives or libraries, they simply collect .o files in a separate block. In fact, this does not complicate the compilation. Read more here .]

1) Follow the first two and a half steps above (including creating the main goal, but not other goals).

2) Go to Utils.cpp and execute Mx ede-new-target ; name: aux ; type: archive . When prompted, add Utils.cpp for this purpose.

3) Go to CGrabBuffer.cpp and execute Cc . a Cc . a ; Target: aux .

4) Restore the Makefile with Mx ede-proj-regenerate . At this point, if you run make in the other subdirectory, you should get the libaux.a archive.

5) Return to main.cpp and execute Mx ede-customize-current-target . This creates an interactive emacs configuration buffer that allows you to edit ede configuration details. In the Ldflags section Ldflags press [INS] . This displays a new line in which Link Flag: is written, and you have a window with different colors for input (my gray). Type -Lother -laux so that other/libaux.a will be included when compiling main . Then at the top of the buffer, click [Accept] , which should save this change and return to main.cpp.

6) Restore the Makefile with Mx ede-proj-regenerate .

Now, unfortunately, the Makefile sets the main target first, then goes down to the other directory and does it. Unfortunately, this means that make from the top-level directory will not work on a clean tree. I don’t know why this is so, because it seems that it will never be what you want in any project that has ever been done with EDE. I cannot find a way to change this other than this hack:

7) Do Mx customize-project ; in the Inference-Rules section, click [INS] . Then enter Target: all ; Dependencies: aux main ; Rules: [INS] ; String @: (This is the last to prevent an error with an empty tab rule, presumably an EDE error.) Click [Accept] and regenerate the Make files.

So now in your top directory you can just run make, and main should be a working executable.

I quickly become convinced that EDE is not yet ready for use by people who are not its authors. Despite its size and the amount of effort that they clearly put into it, it is too buggy, too controversial and not smart enough. It's a shame. Emacs needs this.

+3
source

All Articles