I'm using stxxl library, and recently I noticed that compile time is significantly increased. Therefore, I tried to make use of precompiled header files.
This is the content of "precompiled.h"
Code:
#include <iostream>
#include <stxxl/vector>
#include <stxxl/priority_queue>
#include <stxxl/sort>
#include <stxxl/scan>
#include <stxxl/stream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <vector>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <fstream>
#include <cairo.h>
#include <cairo-pdf.h>
#include <myFile1.cpp>
#include <myFile2.cpp>
and the content of a specific corresponding makefile is
Code:
STXXL_ROOT ?= /home/mirza/stxxl-1.2.1
STXXL_CONFIG ?= stxxl.mk
include $(STXXL_ROOT)/$(STXXL_CONFIG)
# use the variables from stxxl.mk
CXX = $(STXXL_CXX)
CPPFLAGS += $(STXXL_CPPFLAGS)
# add your own optimization, warning, debug, ... flags
# (these are *not* set in stxxl.mk)
CPPFLAGS += $(shell pkg-config --cflags cairo)
STXXL_LDLIBS += $(shell pkg-config --libs cairo)
CPPFLAGS += -O3 -Wall -g -c -DFOO=BAR
# build your application
# (my_example.o is generated from my_example.cpp automatically)
precompiled.o: precompiled.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) precompiled.h -o $@ $(STXXL_LDLIBS)
The first line of the .cpp file is "include "precompiled.h", but after invoking makefile specific for that .cpp file, I get reports and warnings that I got when invoking makefile specific for header file. So, it seems that it compiles again. I've read that the precompiled header files produce .gch files that are automatically sought to be incorporated. In my header specific makefile I could not "tell the compiler" I want .gch as output to be later used by main .cpp file. It only accepts .o.
Any thoughts on how to do this properly?
Thanks
To, maybe, make things easier, I include the content of the makefile specific for the fileA.cpp, which is main file, and contains "include "precompiled.h"" line
Code:
STXXL_ROOT ?= /home/mirza/stxxl-1.2.1
STXXL_CONFIG ?= stxxl.mk
include $(STXXL_ROOT)/$(STXXL_CONFIG)
# use the variables from stxxl.mk
CXX = $(STXXL_CXX)
CPPFLAGS += $(STXXL_CPPFLAGS)
# add your own optimization, warning, debug, ... flags
# (these are *not* set in stxxl.mk)
CPPFLAGS += $(shell pkg-config --cflags cairo)
STXXL_LDLIBS += $(shell pkg-config --libs cairo)
CPPFLAGS += -O3 -Wall -g -DFOO=BAR
# build your application
# (my_example.o is generated from my_example.cpp automatically)
fileA.bin: fileA.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) fileA.o -o $@ $(STXXL_LDLIBS)
Maybe changing this file would make things easier? Thanks