Victor Mion
Victor Mion

Reputation: 21

How do I build a C++ project using Eclipse CDT?

I cloned a git repository from github (a project called plumed) and in order to install it I used to execute the following commands from the terminal:

> ./configure --enable-debug
> make -j 4
> make install

After that checking that everything was ok I used to execute the command

> which plumed
> /usr/local/plumed

How can I do the same from Eclipse? Building from eclipse looks like to execute the command "make all" that returns errors.

Upvotes: 1

Views: 61

Answers (1)

Galik
Galik

Reputation: 48615

Here is what I do, hope it helps.

I make a build directory, cd into that and run configure from there. That will produce a Makefile in the build directory. Then I create a Makefile project in eclipse. Open the Makefile. Then, on the right hand side, in the Outline window you can select the make targets you want to use (all, clean, install, uninstall ...).

You can make several build directories for different configurations (build-debug, build-release etc...).

In fact I have a script for each build type that sets various build flags and calls configure with the relevant flags:

#!/bin/bash

top_dir=$(pwd)

PREFIX=${PREFIX:-$HOME/dev}
LIBDIR=$PREFIX/lib

WITH="$WITH --with-mysql=yes"
WITH="$WITH --with-speller=yes"

export PKG_CONFIG_PATH="$LIBDIR/pkgconfig"
export CXXFLAGS="-g3 -O0 -D DEBUG"

rm -fr $top_dir/build-debug
mkdir -p $top_dir/build-debug

cd $top_dir/build-debug
$top_dir/configure $WITH --prefix=$PREFIX

In eclipse I always make the --prefix point to install within the $HOME folders so you don't need root privilege to install everything.

Upvotes: 1

Related Questions