Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse c++ How to work with existing makefile

I'm a newbie and I've a problem! I've to work with a c++ code and I don't know how to import it and how to compile it on eclips ( I compiled it by command line). The code has a particular structure and it is organized in this way:

repos____lib____configure (execute the configure file inside the libraries folders)
                  I           I___makefile (execute the make file inside the libraries folders,
                                                        requires make/make.def)
      I           I___ib1____.cpp
      I           I            I____.h
      I           ...          I____configure (it requires make/configure_lib and
                                                              make/configure_includes
      I           ...          I____makefile (generated by configure)
      I           I___lib2___....
      i           I___.......
      I           I___libn____.cpp
      i                        I____.h
      i                        I____configure
      i                        I____makefile (generated by configure)
      I
      I___make(folder)__bashrc (are set the some environment variables)
      I                               I__configure_bin
      I                               I__configure_includes
      I                               I__configure_lib
      I                               I__make.def (are set all the include path and library path used
      I                                                         in the configure file)
      I___application__main.cpp
                                   I__configure
                                   I__makefile(generated by the configure file)

to be sure that you understand my problem...(sure... :) )

the first configure file is:

cd lib1; ./configure
cd ../lib2; ./configure
.....
....
cd ../libn; ./configure
cd

and the first makefile is

include /media/Dati/WORKHOME/repos/make/make.def

this is the makefile for the whole library

lib:
    make -C lib1
    make -C lib2
    make -C libn

an example of configure file (the one inside lib1):

   #!/usr/bin/perl

$INC = '$(OPENCVINC) $(FLTKINC) $(DC1394V2INC)';  ##<-DEFINED IN /make.def
$LIB = '$(OPENCVLIB) $(FLTKLIB) $(DC1394V2LIB)';      #####################

#-------------------------------------------------------------------------------

require '/media/Dati/WORKHOME/repos/make/configure_lib';
print "Created Makefile.\n";

# this will create a include file for the whole directory, 
# using the template <dirname>.h.templ
require '/media/Dati/WORKHOME/repos/make/configure_includes';
print "Created $libname.h\n";

compile it without eclipse is simple

  1. type /.configure in the lib folder
  2. type make
  3. go into the application folder
  4. type ./configure
  5. type make
  6. run the program

my question is....in eclipse??? I imported the three with import/ import existing code as makefile project but now I don't know how compile it. could you please help me? it's important!

thank you very much gabriele

like image 461
gabriele Avatar asked Dec 06 '10 16:12

gabriele


People also ask

Where is the makefile located in Eclipse?

By default you should have [workspace]/[project folder]/Debug/makefile.

What is make target in Eclipse?

A "make target" provides a way for developers to interactively select a makefile target from within the Eclipse environment. It is assumed that the makefile is named makefile , which will allow it to run with the default build tool configuration. This can be changed but is cleaner if defaults are used.

Can I compile C on Eclipse?

To use Eclipse for C/C++ programming, you need a C/C++ compiler. On Windows, you could install either MinGW GCC or Cygwin GCC. Choose MinGW if you are not sure, because MinGW is lighter and easier to install, but having less features.


1 Answers

You have done the right thing by using "import existing code as makefile project". Now eclipse know that it needs to call make and use your makefile. But Your build process is not only driven by make.

One solution is to write a makefile that call all your build steps. Something Like :

all:
    cd dir1 && ./configure && make
    cd dir2 && ./configure && make 
    etc.

my2c

Edit:

I currently have no eclipse installed, so I can not send you detailled steps ... sorry

like image 198
neuro Avatar answered Nov 11 '22 21:11

neuro