Building Multiple Binaries Within One Eclipse Project

Building multiple binaries within one Eclipse project

Solution for this described there: http://tinyguides.blogspot.ru/2013/04/multiple-binaries-in-single-eclipse-cdt.html.
There is an excerpt:

  1. Create a managed project (File > New C++ Project > Executable)
  2. Add the source code containing multiple main() functions
  3. Go to Project > Properties > C/C++ General > Path & Symbols > Manage Configurations
  4. Make a build configuration for each executable and name it appropriately (you can clone existing configurations like Debug and Release).
  5. From the project explorer, right click on each source file that contains a main() function > Resource Configurations > Exclude from Build and exclude all build configurations except the one that builds the executable with this main() function
  6. All other code is included in all build configurations by default. You may need to change this depending on your application.
  7. You can now build an executable for each main function by going to Project > Build Configurations > Set Active , Project > Build Project

Project with multiple binaries in Eclipse CDT

I am quite sure CDT doesn't support sub-projects, which leaves you pretty much with:

  • one workspace per "set of projects"
  • one project per binary (like you mention in your question)
  • project dependencies (like you mention in your question)

In term of version control, that means:

  • submodules (Git),
  • subrepos (Mercurial) or
  • external (SVN)

for each project needing a shared library project.

In short, that means putting under version control various components (set of files), with one referencing specific version of others (that list of specific versions of other components is called a "configuration", based on a component-based approach development)

How to build from multiple source files at once in Eclipse

Try using CMake
As per my understanding of your question, you would need to add your source files into CMakeList.txt and then run it. You can make use of this tutorial in doing so.

Eclipse CDT : How to manage multiple main() functions in a single C++ project?

It is possible to deal with multiple main functions in Eclipse CDT by writting a custom makefile. It is a potential solution for C/C++ projects dealing with a main application and its components testbenches, for instance.

See here how to specify a custom makefile in Eclipse.

Then, define a main rule (see makefile documentation) building your whole application (without the testbenches) and define one additional rule for each of your testbenches (with its component) to be built.

To summarize : define one rule in your makefile for each of your main function, building the main and its dependencies.

Having 2 or more main() methods in C with Eclipse

Yes, you better to split your project. And may be it's better to make 3 different projects: server, client, shared library for common functions.

Project builds. Yet it doesn't create the binaries folder

Do you see the file under "binaries" virtual folder in your Project Explorer?

It looks like you "binary parser" is not picking the executable. Do you use CDT-generated makefile or the one you wrote yourself? Also check if "PE Windows Parser" and/or "Cygwin PE Parser" are selected when you open project properties, navigate to "C/C++ Build"/Settings page and "Binary Parsers" tab.

Is it possible to build a java project only once using eclipse and share?

Build once and share it offline

In Maven, you can build your project only once and get a JAR file fully packed with all dependencies. So that, you can share this JAR to other machines off-line.

Below are the steps to make it.

  1. First update your pom.xml with the below setting
 <build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.thanga.MyTest[REPLACE WITH YOUR MAIN CLASS]</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>


  1. Package your project with the goal package assembly:single as shown below

In console,

 mvn package assembly:single

In eclipse,

Sample Image



  1. Run this and you can get the two JAR files. One of them MyFullPack-0.0.1-SNAPSHOT-jar-with-dependencies.jar has the full
    dependencies loaded.

Sample Image



  1. You can open the JAR to see the dependencies are packed as shown below.

Sample Image



  1. You can share this JAR to other machines off-line without any more build



Related Topics



Leave a reply



Submit