0

I would like to be able to compile a c++ source file without using a makefile. And here is a prototype of my problem... I have the following .cpp file

// special libraries to include
#include "acado.h"  
#include "auxiliary_functions.c" 
/* -------------------------- */
// Create objects for special classes 
   ACADOvariables acadoVariables; 
   ACADOworkspace acadoWorkspace;

int main(){
    // perform task A_1
    // perform task A_2 
    // Tasks A_1 and A_2 depend on the specially included headers
    return 0;
}

and in the same directory I have the following makefile that allows me to compile the .cpp file successfully

LDLIBS = -lm 
CXXFLAGS = -O3 -finline-functions -I. -I./qpoases/INCLUDE -I./qpoases/SRC
CFLAGS = -O3
CC     = g++

OBJECTS = \
    ./qpoases/SRC/QProblemB.o       \
    ./qpoases/SRC/Bounds.o          \
    ./qpoases/SRC/Constraints.o     \
    ./qpoases/SRC/SubjectTo.o       \
    ./qpoases/SRC/Indexlist.o       \
    ./qpoases/SRC/CyclingManager.o  \
    ./qpoases/SRC/Utils.o           \
    ./qpoases/SRC/MessageHandling.o \
    ./qpoases/solver.o              \
    integrator.o                    \
    condensing.o                    \
    gauss_newton_method.o 

.PHONY: all
all: test libacado_exported_rti.a

test: ${OBJECTS} test.o

./qpoases/solver.o    : ./qpoases/solver.hpp
integrator.o          : acado.h
condensing.o          : acado.h
gauss_newton_method.o : acado.h   ./qpoases/solver.hpp
test.o                : acado.h   ./qpoases/solver.hpp

libacado_exported_rti.a: ${OBJECTS}
    ar r $@ $?

${OBJECTS} : ./qpoases/solver.hpp

.PHONY : clean
clean :
    -rm -f *.o *.a ./qpoases/SRC/*.o ./qpoases/SRC/*.a test

Now, for my purposes, I would like to delete this makefile from the .cpp file directory. At the same time, I would like to be able to compile the .cpp file ...

Knowing that the object files and libraries that the makefile refers to will be at their respective directories ....

So, everything I would like to do, is to compile the .cpp file without having a makefile.

Is it possible to do something like this for the given case ? ... If yes, your suggestions are really appreciated !

user2056096
  • 85
  • 1
  • 5
  • Where exactly is the problem? Just reproduce the steps in the makefile manually. – us2012 Feb 14 '13 at 21:50
  • 3
    Sometimes I wonder if some of the people posting questions here are masochists. If it's not wanting to do things the hard way without using the C library, it's doing things the hard way without using make. Yes, you can do this by writing a script file that compiles all the files (every time, so it will take longer than using make) - just put all the commands that your makefile contains into a script file. If you don't like that idea, why not just typing it all in by hand? – Mats Petersson Feb 14 '13 at 22:04
  • Can you use another build system as long as it isn't make? – juanchopanza Feb 14 '13 at 22:11

1 Answers1

2

Assuming that your main() function is in the test.cpp, and you want the executable named "test" you can invoke the compiler directly from the directory where you would invoke make:

 g++ test.cpp -O3 -finline-functions -I. -I./qpoases/INCLUDE -I./qpoases/SRC -lm -o test ./qpoases/SRC/QProblemB.o ./qpoases/SRC/Bounds.o ./qpoases/SRC/Constraints.o ./qpoases/SRC/SubjectTo.o ./qpoases/SRC/Indexlist.o ./qpoases/SRC/CyclingManager.o ./qpoases/SRC/Utils.o ./qpoases/SRC/MessageHandling.o ./qpoases/solver.o integrator.o condensing.o gauss_newton_method.o
Ferenc Géczi
  • 563
  • 3
  • 6