Issues compiling Qt project with Google Protocol Buffer - c++

I am building a network application with Qt and Protocol Buffer. I have a server, which can be compiled successfully, and a Qt client, which cannot be compiled with Protocol Buffer.
The server is built by running make on the following Makefile
PWD := $(shell pwd)
CXX := g++
LINKER := g++
INCDIRS := -I. -I$(PWD)/lib -I$(PWD)/lib/protobuf-2.6.1/src
LIBDIRS := $(PWD)/lib/protobuf-2.6.1/src/.libs
LIBS := -l protobuf
CXXFLAGS := -std=c++11 -pthread -g #-Wall -Wextra
BUILD_DIR=build
BIN := $(BUILD_DIR)/bin
PROTO := $(shell bash -c "pwd")/lib/protobuf-2.6.1/src/protoc
MODEL_DIR := model
MODEL_BUILD_DIR := build
BIN := $(BUILD_DIR)/bin
MODELS := $(shell bash -c "cd $(MODEL_DIR) && ls *.proto")
MODELS_SRCFILES := $(patsubst %.proto, %.pb.cc, $(MODELS))
MODELS_OBJFILES := $(addprefix $(MODEL_DIR)/$(MODEL_BUILD_DIR)/, $(patsubst %.cc,%.o,$(MODELS_SRCFILES)))
INCDIRS += -I$(MODEL_DIR)/$(MODEL_BUILD_DIR)
SERVER_DIR := server
SERVER_SRCFILES := $(wildcard $(SERVER_DIR)/*.cpp)
SERVER_OBJFILES := $(addprefix $(BIN)/, $(patsubst %.cpp,%.o,$(SERVER_SRCFILES)))
SERVER_BUILD := $(BUILD_DIR)/server
CLIENT_DIR := client
QMAKE := qmake
LIB_DIR := lib
LIB_SRCFILES := $(wildcard $(LIB_DIR)/*.cpp)
LIB_OBJFILES := $(addprefix $(BIN)/, $(patsubst %.cpp,%.o,$(LIB_SRCFILES)))
.PHONY: init_dir clean client model
all: init_dir model $(SERVER_BUILD)
run:
#export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIRS) && ./build/server
run_client:
#export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIRS) && ./build/client
init_dir:
#mkdir -p $(BIN)/$(SERVER_DIR) $(BIN)/$(MODEL_DIR) $(MODEL_DIR)/$(MODEL_BUILD_DIR) $(BIN)/$(LIB_DIR)
model: $(addprefix, $(MODEL_DIR)/, $(MODELS))
#cd $(MODEL_DIR) && \
for model in $(MODELS); do echo proto compiling $$model; \
$(PROTO) -I=. --cpp_out=./$(MODEL_BUILD_DIR) $$model; done && \
cd $(MODEL_BUILD_DIR) && \
for modelcc in $(MODELS_SRCFILES); do echo compiling $$modelcc; $(CXX) $(CXXFLAGS) $(INCDIRS) -c $$modelcc ; done
$(SERVER_BUILD): $(LIB_OBJFILES) $(MODELS_OBJFILES) $(SERVER_OBJFILES)
$(LINKER) $^ -L $(LIBDIRS) $(LIBS) -o $#
$(BIN)/$(SERVER_DIR)/%.o: $(SERVER_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $#
$(BIN)/$(LIB_DIR)/%.o: $(LIB_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $#
client:
#cd $(CLIENT_DIR) && $(QMAKE) && $(MAKE)
clean:
rm -rf $(BUILD_DIR) $(MODEL_DIR)/$(MODEL_BUILD_DIR)/*
The client Qt project uses this .pro:
QT += core gui
CONFIG += c++11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = client
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
../model/build/main.model.pb.cc \
../model/build/guess.model.pb.cc \
../model/build/jack.model.pb.cc \
../model/build/system.model.pb.cc \
changename.cpp
HEADERS += mainwindow.h \
../model/build/main.model.pb.h \
../model/build/guess.model.pb.h \
../model/build/jack.model.pb.h \
../model/build/system.model.pb.h \
FORMS += mainwindow.ui \
DESTDIR=../build
OBJECTS_DIR=../build/bin/client
MOC_DIR=../build/bin/client
unix:!macx: LIBS += -L../lib/protobuf-2.6.1/src/.libs/ -lprotoc
INCLUDEPATH += ../lib/protobuf-2.6.1/src/.libs ../lib ../model/build/
DEPENDPATH += ../lib/protobuf-2.6.1/src/.libs
unix:!macx: PRE_TARGETDEPS += ../lib/protobuf-2.6.1/src/.libs/libprotoc.a
The four protoc generated files, i.e. ../model/build/*.model.pb.h, is generated by make model.
My issue is that running make model alone can successfully compile the protocol buffer implementation files. But including them as SOURCES and compile them with qmake generated Makefile does not work.
The error is as follow:
g++ -c -m64 -pipe -O2 -std=c++0x -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I../lib/protobuf-2.6.1/src/.libs -I../lib -I../model/build -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I../build/bin/client -I. -o ../build/bin/client/main.o main.cpp
In file included from mainwindow.h:6:0,
from main.cpp:1:
../model/build/main.model.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
../model/build/main.model.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
../model/build/main.model.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from ../model/build/main.model.pb.h:27:0,
from mainwindow.h:6,
from main.cpp:1:
../model/build/jack.model.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
../model/build/jack.model.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
../model/build/jack.model.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from ../model/build/main.model.pb.h:28:0,
from mainwindow.h:6,
from main.cpp:1:
../model/build/system.model.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
../model/build/system.model.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
../model/build/system.model.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from ../model/build/system.model.pb.h:28:0,
from ../model/build/main.model.pb.h:28,
from mainwindow.h:6,
from main.cpp:1:
../model/build/guess.model.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
../model/build/guess.model.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
../model/build/guess.model.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from ../model/build/main.model.pb.h:27:0,
from mainwindow.h:6,
from main.cpp:1:
../model/build/jack.model.pb.h: In member function ‘void BlackJack::Request::clear_command()’:
../model/build/jack.model.pb.h:297:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h: In member function ‘void BlackJack::Request::set_command(const string&)’:
../model/build/jack.model.pb.h:308:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h: In member function ‘void BlackJack::Request::set_command(const char*)’:
../model/build/jack.model.pb.h:316:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h: In member function ‘void BlackJack::Request::set_command(const char*, size_t)’:
../model/build/jack.model.pb.h:324:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h: In member function ‘std::string* BlackJack::Request::mutable_command()’:
../model/build/jack.model.pb.h:332:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h: In member function ‘std::string* BlackJack::Request::release_command()’:
../model/build/jack.model.pb.h:340:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h:344:45: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
command_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
^
../model/build/jack.model.pb.h: In member function ‘void BlackJack::Request::set_allocated_command(std::string*)’:
../model/build/jack.model.pb.h:349:20: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
if (command_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
^
../model/build/jack.model.pb.h:357:45: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
command_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
^
What could be the problem??
Thanks for your help

Related

#error This file requires compiler and library support for the ISO C++ 2011 standard

I'm in Ubuntu 16.04.3 LTS xenial and I'm trying to run the command make on the terminal, but I'm getting this error:
g++ -g -O2 -Wall -Wuninitialized -fno-strict-aliasing -Iinclude -
I/usr/local/include -DOS_LINUX -DHAVE_USB -DHAVE_LIBUSB10 -
DUSE_DRS_MUTEX -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-
3.1-unofficial3 -I/usr/include/wx-3.1-unofficial -
D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c src/DRS.cpp
In file included from /usr/include/c++/5/type_traits:35:0,
from /usr/include/wx-3.1-unofficial/wx/strvararg.h:22,
from /usr/include/wx-3.1-unofficial/wx/string.h:37,
from /usr/include/wx-3.1-unofficial/wx/memory.h:15,
from /usr/include/wx-3.1-unofficial/wx/object.h:19,
from /usr/include/wx-3.1-unofficial/wx/wx.h:15,
from src/DRS.cpp:15:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file
requires compiler and library support for the ISO C++ 2011 standard.
This support must be enabled with the -std=c++11 or -std=gnu++11 c
ompiler options.
#error This file requires compiler and library support \
^
In file included from /usr/include/wx-3.1-unofficial/wx/string.h:37:0,
from /usr/include/wx-3.1-unofficial/wx/memory.h:15,
from /usr/include/wx-3.1-unofficial/wx/object.h:19,
from /usr/include/wx-3.1-unofficial/wx/wx.h:15,
from src/DRS.cpp:15:
/usr/include/wx-3.1-unofficial/wx/strvararg.h:345:18: error: ‘is_enum’
in namespace ‘std’ does not name a template type
typedef std::is_enum<T> is_enum;
^
/usr/include/wx-3.1-unofficial/wx/strvararg.h:349:54: error: ‘is_enum’
was not declared in this scope
enum { value =
wxFormatStringSpecifierNonPodType<is_enum::value>::value };
^
/usr/include/wx-3.1-unofficial/wx/strvararg.h:349:68: error: template
argument 1 is invalid
enum { value =
wxFormatStringSpecifierNonPodType<is_enum::value>::value };
^
src/DRS.cpp: In member function ‘void DRSBoard::InteractSpeed()’:
src/DRS.cpp:3986:25: warning: ignoring return value of ‘int
scanf(const char*, ...)’, declared with attribute warn_unused_result
[-Wunused-result]
scanf("%lf", &vds);
^
Makefile:81: recipe for target 'DRS.o' failed
make: *** [DRS.o] Error 1
I think that I must do this correction:
This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
I have never tried to do something like this before, so I don't know how to correct.
Follows the makefile:
# check if wxWidgets is installed
HAVE_WX = $(shell which wx-config)
ifeq ($(HAVE_WX),)
$(error Error: wxWidgets required to compile "drsosc")
endif
# check for OS
OS = $(shell uname)
ifeq ($(OS),Darwin)
DOS = OS_DARWIN
else
DOS = OS_LINUX
endif
CFLAGS = -g -O2 -Wall -Wuninitialized -fno-strict-aliasing -
Iinclude -I/usr/local/include -D$(DOS) -DHAVE_USB -DHAVE_LIBUSB10 -
DUSE_DRS_MUTEX
LIBS = -lpthread -lutil -lusb-1.0
ifeq ($(OS),Darwin)
CFLAGS += -stdlib=libstdc++
endif
# wxWidgets libs and flags
WXLIBS = $(shell wx-config --libs)
WXFLAGS = $(shell wx-config --cxxflags)
CPP_OBJ = DRS.o averager.o ConfigDialog.o DOFrame.o DOScreen.o
DRSOsc.o MeasureDialog.o Measurement.o Osci.o InfoDialog.o
DisplayDialog.o AboutDialog.o EPThread.o TriggerDialog.o rb.o
OBJECTS = musbstd.o mxml.o strlcpy.o
ifeq ($(OS),Darwin)
all: drsosc drscl drs_exam drs_exam_multi DRSOsc.app
else
all: drsosc drscl drs_exam drs_exam_multi
endif
DRSOsc.app: drsosc
-mkdir DRSOsc.app
-mkdir DRSOsc.app/Contents
-mkdir DRSOsc.app/Contents/MacOS
-mkdir DRSOsc.app/Contents/Resources
-mkdir DRSOsc.app/Contents/Resources/English.lproj
echo 'APPL????' > DRSOsc.app/Contents/PkgInfo
cp Info.plist DRSOsc.app/Contents/Info.plist
cp DRSOsc.icns DRSOsc.app/Contents/Resources
cp drsosc DRSOsc.app/Contents/MacOS/DRSOsc
drsosc: $(OBJECTS) $(CPP_OBJ) main.o
$(CXX) $(CFLAGS) $(OBJECTS) $(CPP_OBJ) main.o -o drsosc $(LIBS)
$(WXLIBS)
drscl: $(OBJECTS) DRS.o averager.o drscl.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drscl.o -o drscl
$(LIBS) $(WXLIBS)
drs_exam: $(OBJECTS) DRS.o averager.o drs_exam.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drs_exam.o -o drs_exam
$(LIBS) $(WXLIBS)
drs_exam_multi: $(OBJECTS) DRS.o averager.o drs_exam_multi.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drs_exam_multi.o -o
drs_exam_multi $(LIBS) $(WXLIBS)
main.o: src/main.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) $(WXFLAGS) -c $<
drscl.o: src/drscl.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
drs_exam.o: src/drs_exam.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
drs_exam_multi.o: src/drs_exam_multi.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
$(CPP_OBJ): %.o: src/%.cpp include/%.h include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) $(WXFLAGS) -c $<
$(OBJECTS): %.o: src/%.c include/mxml.h include/DRS.h
$(CC) $(CFLAGS) -c $<
clean:
rm -f *.o drscl drsosc
In my research I didn't find anything helpful.
Sorry for the long post, couldn't make it more simple.
You simply need to set the C++ standard by adding it to the CFLAGS, ie:
CFLAGS += -std=c++11
I have the same problem you have and I was looking for an answer but can't find one so I solved it on my own. In my case, the problem is with the string.h header file I removed it and my code is working now.

Makefile issue when adding option to show percentage

I tried to add to my Makefile an option to display the percentage of the compile process.
However it doesnt compile correctly now, it seems i have created in some way a loop.
My Makefile:
SHELL = /bin/sh
SYSTEM = $(shell uname)
C++ = g++
CC = gcc
DFLAGS = -DGHOST_MYSQL
OFLAGS = -O3
LFLAGS = -L. -L../bncsutil/src/bncsutil/ -L../StormLib/stormlib/ -L/usr/local/lib/Poco/ -lPocoNet -lPocoFoundation -lbncsutil -lpthread -ldl -lz -lStorm -lmysqlclient_r -lboost_date_time -lboost_thread -lboost_system -lboost_filesystem -lgmp
CFLAGS =
ifeq ($(SYSTEM),Darwin)
DFLAGS += -D__APPLE__
OFLAGS += -flat_namespace
else
LFLAGS += -lrt
endif
ifeq ($(SYSTEM),FreeBSD)
DFLAGS += -D__FREEBSD__
endif
ifeq ($(SYSTEM),SunOS)
DFLAGS += -D__SOLARIS__
LFLAGS += -lresolv -lsocket -lnsl
endif
CFLAGS += $(OFLAGS) $(DFLAGS) -I. -I../bncsutil/src/ -I../StormLib/
ifeq ($(SYSTEM),Darwin)
CFLAGS += -I../mysql/include/
endif
## PRINT_PROGRESS is initially undefined
ifndef PRINT_PROGRESS
# T estimates how many targets we are building by replacing PRINT_PROGRESS with a special string
T := $(shell $(MAKE) $(MAKECMDGOALS) --no-print-directory \
-rRf $(firstword $(MAKEFILE_LIST)) \
PRINT_PROGRESS="echo COUNTTHIS" BUILD="test x ||" | grep -c "COUNTTHIS")
N := 1
## PRINT_PROGRESS is now defined to show the progress and update N
PRINT_PROGRESS = echo "`expr " [\`expr $N '*' 100 / $T\`" : '.*\(....\)$$'`%]"$(eval N := $(shell expr $N + 1))
endif
OBJS = bncsutilinterface.o bnet.o bnetprotocol.o bnlsclient.o bnlsprotocol.o commandpacket.o config.o crc32.o csvparser.o game.o game_base.o gameplayer.o gameprotocol.o gameslot.o ghost.o ghostdb.o ghostdbmysql.o gpsprotocol.o language.o map.o packed.o replay.o savegame.o sha1.o socket.o stats.o statsdota.o util.o
COBJS =
PROGS = ./ghost++
all: $(OBJS) $(COBJS) $(PROGS)
./ghost++: $(OBJS) $(COBJS)
$(C++) -o ./ghost++ $(OBJS) $(COBJS) $(LFLAGS)
clean:
rm -f $(OBJS) $(COBJS) $(PROGS)
$(OBJS): %.o: %.cpp
#$(PRINT_PROGRESS) $(C++) -o $# $(CFLAGS) -c $<
$(COBJS): %.o: %.c
#$(PRINT_PROGRESS) $(CC) -o $# $(CFLAGS) -c $<
./ghost++: $(OBJS) $(COBJS)
all: $(PROGS)
bncsutilinterface.o: ghost.h includes.h util.h bncsutilinterface.h
bnet.o: ghost.h includes.h util.h config.h language.h socket.h commandpacket.h ghostdb.h bncsutilinterface.h bnlsclient.h bnetprotocol.h bnet.h map.h packed.h savegame.h replay.h gameprotocol.h game_base.h
bnetprotocol.o: ghost.h includes.h util.h bnetprotocol.h
bnlsclient.o: ghost.h includes.h util.h socket.h commandpacket.h bnlsprotocol.h bnlsclient.h
bnlsprotocol.o: ghost.h includes.h util.h bnlsprotocol.h
commandpacket.o: ghost.h includes.h commandpacket.h
config.o: ghost.h includes.h config.h
crc32.o: ghost.h includes.h crc32.h
csvparser.o: csvparser.h
game.o: ghost.h includes.h util.h config.h language.h socket.h ghostdb.h bnet.h map.h packed.h savegame.h gameplayer.h gameprotocol.h game_base.h game.h stats.h statsdota.h
game_base.o: ghost.h includes.h util.h config.h language.h socket.h ghostdb.h bnet.h map.h packed.h savegame.h replay.h gameplayer.h gameprotocol.h game_base.h next_combination.h
gameplayer.o: ghost.h includes.h util.h language.h socket.h commandpacket.h bnet.h map.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h
gameprotocol.o: ghost.h includes.h util.h crc32.h gameplayer.h gameprotocol.h game_base.h
gameslot.o: ghost.h includes.h gameslot.h
ghost.o: ghost.h includes.h util.h crc32.h sha1.h csvparser.h config.h language.h socket.h ghostdb.h ghostdbmysql.h bnet.h map.h packed.h savegame.h gameplayer.h gameprotocol.h gpsprotocol.h game_base.h game.h
ghostdb.o: ghost.h includes.h util.h config.h ghostdb.h
ghostdbmysql.o: ghost.h includes.h util.h config.h ghostdb.h ghostdbmysql.h
gpsprotocol.o: ghost.h util.h gpsprotocol.h
language.o: ghost.h includes.h config.h language.h
map.o: ghost.h includes.h util.h crc32.h sha1.h config.h map.h
packed.o: ghost.h includes.h util.h crc32.h packed.h
replay.o: ghost.h includes.h util.h packed.h replay.h gameprotocol.h
savegame.o: ghost.h includes.h util.h packed.h savegame.h
sha1.o: sha1.h
socket.o: ghost.h includes.h util.h socket.h
stats.o: ghost.h includes.h stats.h
statsdota.o: ghost.h includes.h util.h ghostdb.h gameplayer.h gameprotocol.h game_base.h stats.h statsdota.h
util.o: ghost.h includes.h util.h
The part I added here was:
## PRINT_PROGRESS is initially undefined
ifndef PRINT_PROGRESS
# T estimates how many targets we are building by replacing PRINT_PROGRESS with a special string
T := $(shell $(MAKE) $(MAKECMDGOALS) --no-print-directory \
-rRf $(firstword $(MAKEFILE_LIST)) \
PRINT_PROGRESS="echo COUNTTHIS" BUILD="test x ||" | grep -c "COUNTTHIS")
N := 1
## PRINT_PROGRESS is now defined to show the progress and update N
PRINT_PROGRESS = echo "`expr " [\`expr $N '*' 100 / $T\`" : '.*\(....\)$$'`%]"$(eval N := $(shell expr $N + 1))
endif
And the change of these lines:
$(OBJS): %.o: %.cpp
$(C++) -o $# $(CFLAGS) -c $<
$(COBJS): %.o: %.c
$(CC) -o $# $(CFLAGS) -c $<
to
$(OBJS): %.o: %.cpp
#$(PRINT_PROGRESS) $(C++) -o $# $(CFLAGS) -c $<
$(COBJS): %.o: %.c
#$(PRINT_PROGRESS) $(CC) -o $# $(CFLAGS) -c $<
The displayed output when compiling is now this:
$ make
g++: error: bncsutilinterface.o: No such file or directory
g++: error: bnet.o: No such file or directory
g++: error: bnetprotocol.o: No such file or directory
g++: error: bnlsclient.o: No such file or directory
g++: error: bnlsprotocol.o: No such file or directory
g++: error: commandpacket.o: No such file or directory
g++: error: config.o: No such file or directory
g++: error: crc32.o: No such file or directory
g++: error: csvparser.o: No such file or directory
g++: error: game.o: No such file or directory
g++: error: game_base.o: No such file or directory
g++: error: gameplayer.o: No such file or directory
g++: error: gameprotocol.o: No such file or directory
g++: error: gameslot.o: No such file or directory
g++: error: ghost.o: No such file or directory
g++: error: ghostdb.o: No such file or directory
g++: error: ghostdbmysql.o: No such file or directory
g++: error: gpsprotocol.o: No such file or directory
g++: error: language.o: No such file or directory
g++: error: map.o: No such file or directory
g++: error: packed.o: No such file or directory
g++: error: replay.o: No such file or directory
g++: error: savegame.o: No such file or directory
g++: error: sha1.o: No such file or directory
g++: error: socket.o: No such file or directory
g++: error: stats.o: No such file or directory
g++: error: statsdota.o: No such file or directory
g++: error: util.o: No such file or directory
make: *** [ghost++] Error 1
[3%] g++ -o bncsutilinterface.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c bncsutilinterface.cpp
[7%] g++ -o bnet.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c bnet.cpp
[10%] g++ -o bnetprotocol.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c bnetprotocol.cpp
[14%] g++ -o bnlsclient.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c bnlsclient.cpp
[17%] g++ -o bnlsprotocol.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c bnlsprotocol.cpp
[21%] g++ -o commandpacket.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c commandpacket.cpp
[25%] g++ -o config.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c config.cpp
[28%] g++ -o crc32.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c crc32.cpp
[32%] g++ -o csvparser.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c csvparser.cpp
[35%] g++ -o game.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c game.cpp
[39%] g++ -o game_base.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c game_base.cpp
[42%] g++ -o gameplayer.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c gameplayer.cpp
[46%] g++ -o gameprotocol.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c gameprotocol.cpp
[50%] g++ -o gameslot.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c gameslot.cpp
[53%] g++ -o ghost.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c ghost.cpp
[57%] g++ -o ghostdb.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c ghostdb.cpp
[60%] g++ -o ghostdbmysql.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c ghostdbmysql.cpp
[64%] g++ -o gpsprotocol.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c gpsprotocol.cpp
[67%] g++ -o language.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c language.cpp
[71%] g++ -o map.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c map.cpp
[75%] g++ -o packed.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c packed.cpp
[78%] g++ -o replay.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c replay.cpp
[82%] g++ -o savegame.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c savegame.cpp
[85%] g++ -o sha1.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c sha1.cpp
[89%] g++ -o socket.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c socket.cpp
[92%] g++ -o stats.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c stats.cpp
[96%] g++ -o statsdota.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c statsdota.cpp
[100%] g++ -o util.o -O3 -DGHOST_MYSQL -I. -I../bncsutil/src/ -I../StormLib/ -c util.cpp
g++ -o ./ghost++ bncsutilinterface.o bnet.o bnetprotocol.o bnlsclient.o bnlsprotocol.o commandpacket.o config.o crc32.o csvparser.o game.o game_base.o gameplayer.o gameprotocol.o gameslot.o ghost.o ghostdb.o ghostdbmysql.o gpsprotocol.o language.o map.o packed.o replay.o savegame.o sha1.o socket.o stats.o statsdota.o util.o -L. -L../bncsutil/src/bncsutil/ -L../StormLib/stormlib/ -L/usr/local/lib/Poco/ -lPocoNet -lPocoFoundation -lbncsutil -lpthread -ldl -lz -lStorm -lmysqlclient_r -lboost_date_time -lboost_thread -lboost_system -lboost_filesystem -lgmp -lrt
g++: error: bncsutilinterface.o: No such file or directory
g++: error: bnet.o: No such file or directory
g++: error: bnetprotocol.o: No such file or directory
g++: error: bnlsclient.o: No such file or directory
g++: error: bnlsprotocol.o: No such file or directory
g++: error: commandpacket.o: No such file or directory
g++: error: config.o: No such file or directory
g++: error: crc32.o: No such file or directory
g++: error: csvparser.o: No such file or directory
g++: error: game.o: No such file or directory
g++: error: game_base.o: No such file or directory
g++: error: gameplayer.o: No such file or directory
g++: error: gameprotocol.o: No such file or directory
g++: error: gameslot.o: No such file or directory
g++: error: ghost.o: No such file or directory
g++: error: ghostdb.o: No such file or directory
g++: error: ghostdbmysql.o: No such file or directory
g++: error: gpsprotocol.o: No such file or directory
g++: error: language.o: No such file or directory
g++: error: map.o: No such file or directory
g++: error: packed.o: No such file or directory
g++: error: replay.o: No such file or directory
g++: error: savegame.o: No such file or directory
g++: error: sha1.o: No such file or directory
g++: error: socket.o: No such file or directory
g++: error: stats.o: No such file or directory
g++: error: statsdota.o: No such file or directory
g++: error: util.o: No such file or directory
make: *** [ghost++] Error 1
The middle part is the actual wanted output.
However, the point is this is displayed in less seconds, like it just showing off but doesnt compile in any way.
What did I made wrong here?
You are passing the compilation commands as arguments to the echo in PRINT_PROGRESS.
#$(PRINT_PROGRESS) $(C++) -o $# $(CFLAGS) -c $<
You need to add a semicolon.
#$(PRINT_PROGRESS); $(C++) -o $# $(CFLAGS) -c $<
That being said I don't think this approach likely only works when each target has to print out one percentage marker (which is likely to be true much, if not all, of the time). Also this will may not play well with use of -j.

CMake - Specifying Linker / Linker Flags during Cross-Compile

I am in the process of converting out previous build system (Makefiles) to CMake. I am trying to specify the Linker and Linker Flags for CMake and am not sure if I am using the correct syntax/variables. I have included my original Makefile (which compiles and genreates the executable) but when attempting to do the smae with CMake I am getting errors.
Here is the error:
Linking CXX executable discoveryService
/home/projects/OMAP- L137/timesys/SDK/omapl137_evm/toolchain/bin/../../toolchain/lib/crt1.o: In function `_start':
(.text+0x34): undefined reference to `main'
collect2: ld returned 1 exit status
make[2]: *** [arm/communications/discoveryService] Error 1
make[1]: *** [arm/communications/CMakeFiles/discoveryService.dir/all] Error 2
make: *** [all] Error 2
The original Makefile used three flags -lpthread -lc & -o If I am understanding correctly the -o just means to name the executable a specific name so with CMake *ADD_EXECUTABLE* I shouldn't need that since we specify the name of the executable there. I have included my 2 CMakeLists and the original Makefile for reference and any help is greatly appreciated since this has stumped me for the second day now..
Top Level CMakeList
INCLUDE(CMakeForceCompiler)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(633)
#this one is important
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
SET(FACTORY_CURRENT /home/projects/OMAP-L137/timesys/factory-current)
SET(DSPLINK_PATH ${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink- 1_65_01/DSPLink-1_65_01)
SET(DSPLINK_PACKAGE_DIR ${FACTORY_CURRENT}/${DSPLINK_PATH})
SET(TOOLCHAIN_LOC ${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/toolchain/bin)
#read file into variable 'defines'
file(READ ${CMAKE_SOURCE_DIR}/arm/dsplink_config/dsplink_defines.txt defines)
#turn space separation into CMake list
string(REPLACE " " ";" defines "${defines}")
ADD_DEFINITIONS(${defines})
# specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++ "-lpthread -lc")
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++ "lpthread -lc")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -c ")
SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
#specify the linker
SET(CMAKE_C_LINK_EXECUTABLE "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l- timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
SET(CMAKE_CXX_LINK_EXECUTABLE "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l-timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
SET(CMAKE_LINKER "/OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin/armv5l-timesys-linux-uclibcgnueabi-g++ -lpthread -lc")
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/projects/OMAP-L137/timesys/factory-current)
SET(PROJECT_SOURCE_DIR /home/chrisk/633/)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/bin)
SET(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
ADD_SUBDIRECTORY(arm)
Second Level CMakeList:
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/arm/framework ${CMAKE_SOURCE_DIR}/arm/flagDictionary
${CMAKE_SOURCE_DIR}/arm/logging ${CMAKE_SOURCE_DIR}/dsp/include ${CMAKE_SOURCE_DIR}/arm/modbus ${CMAKE_SOURCE_DIR}/arm/expat)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP-L137/timesys/factory-20120925-633/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP-L137/timesys/factory-20120925-633/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/sys/Linux/2.6.18)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop/Linux)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/src/samples/loop/Linux/2.6.18)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/BUILD/INCLUDE/USER)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink- 1_65_01/dsplink/gpp/export/INCLUDE/Linux/OMAPL1XX/internal)
INCLUDE_DIRECTORIES(${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/include)
SET(communications_SOURCES
discoveryService.cpp
httpService.cpp
modbusRTUService.cpp
modbusService.cpp
streamingService.cpp
trendMap.cpp
trendService.cpp
tripBuffer.cpp
tripReader.cpp
)
ADD_LIBRARY(communications ${communications_SOURCES})
SET(SET_TARGET_PROPERTIES(libcommunications.a PROPERTIES LINK_FLAGS "-lpthread -lc" ))
SET(SET_TARGET_PROPERTIES(libcommunications.a PROPERTIES LINKER_LANGUAGE CXX))
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/arm/flagDictionary ${CMAKE_SOURCE_DIR}/arm/framework ${CMAKE_SOURCE_DIR}/arm/communications
${DSPLINK_PACKAGE_DIR}/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/ "-lpthread -lc")
ADD_EXECUTABLE(discoveryService discoveryService.cpp)
TARGET_LINK_LIBRARIES(discoveryService flagDictionary framework communications dsplink.lib)
Original Makefile:
$(shell ../../build_environment.sh)
BIN = ../../build/bin
TMP = build
BUILD_DEF = -DBUILD=$(BUILD_VERSION) -DBUILD_DATE=$(BUILD_DATE)
# these files are captured from the DSPLink Sample build directory (and the named changed)
# they contain the appropriate includes and flags to build a dsplink application.
DSPLINK_INCLUDES = $(shell cat ../dsplink_config/dsplink_includes.txt)
DSPLINK_FLAGS = $(shell cat ../dsplink_config/dsplink_flags.txt)
DSPLINK_DEFINES = $(shell cat ../dsplink_config/dsplink_defines.txt)
DSPLINK_LIBS = $(DSPLINK_PACKAGE_DIR)/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplink.lib
#Our project variables
INCLUDE= -I. -I../framework -I../flagDictionary -I../logging -I../../dsp/include - I../modbus -I../expat
TOOLCHAIN = /OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin
#TOOLCHAIN = ${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/bin
PLATFORM=armv5l-timesys-linux-uclibcgnueabi
#Compile Options
CC=$(TOOLCHAIN)/$(PLATFORM)-g++
LINKER=$(TOOLCHAIN)/$(PLATFORM)-g++
CFLAGS+=$(BUILD_DEF) $(INCLUDE)
DEBUG =
#list of things to compile.
FW_BUILD_DIR=../framework/build
LOG_BUILD_DIR=../logging/build
XML_BUILD_DIR=../expat/build
MODBUS_BUILD_DIR=../modbus/build
FLAG_DICT_BUILD_DIR=../flagDictionary/build
CORE_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/application.o \
$(FW_BUILD_DIR)/arguments.o \
$(FW_BUILD_DIR)/com.o \
$(FW_BUILD_DIR)/memoryManagerBase.o \
$(FW_BUILD_DIR)/memoryManager.o \
$(FW_BUILD_DIR)/lockManager.o \
$(FW_BUILD_DIR)/stopWatch.o \
$(FW_BUILD_DIR)/controlCom.o \
$(FW_BUILD_DIR)/status.o \
$(FW_BUILD_DIR)/paths.o \
$(LOG_BUILD_DIR)/subsystemLogMasks.o \
$(LOG_BUILD_DIR)/logger.o
# removed utils.o from CORE
NET_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/message.o \
$(FW_BUILD_DIR)/chunk.o \
$(FW_BUILD_DIR)/multicastSocket.o \
$(FW_BUILD_DIR)/serverSocket.o \
$(FW_BUILD_DIR)/socket.o \
$(FW_BUILD_DIR)/tcpReader.o
CONF_FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/configuration.o \
$(FW_BUILD_DIR)/editConfig.o \
$(FW_BUILD_DIR)/parseConfig.o \
$(FW_BUILD_DIR)/xpath.o \
$(XML_BUILD_DIR)/xmlparse.o \
$(XML_BUILD_DIR)/xmlrole.o \
$(XML_BUILD_DIR)/xmltok.o
MODBUS_OBJECTS= $(MODBUS_BUILD_DIR)/modbus.o \
$(MODBUS_BUILD_DIR)/modbusFacade.o
MODBUS_RTU_OBJECTS= $(MODBUS_BUILD_DIR)/modbus.o \
$(MODBUS_BUILD_DIR)/rtuFacade.o
FLAG_DICT_OBJECTS= $(FLAG_DICT_BUILD_DIR)/flagEntry.o \
$(FLAG_DICT_BUILD_DIR)/flagDictionary.o
OBJECTS = discoveryService.o \
httpService.o \
modbusService.o \
streamingService.o \
trendMap.o \
trendService.o \
tripBuffer.o \
modbusRTUService.o \
tripReader.o
EXES = discoveryService httpService modbusService streamingService trendService tripReader modbusRTUService cmprXfr
all: $(OBJECTS) $(EXES)
.c.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DSPLINK_INCLUDES) $(DSPLINK_FLAGS) $(DSPLINK_DEFINES) $(DEBUG) -o $(TMP)/$# $<
.cpp.o:e
mkdir -p build
$(CC) -c $(CFLAGS) $(DSPLINK_INCLUDES) $(DSPLINK_FLAGS) $(DSPLINK_DEFINES) $(DEBUG) -o $(TMP)/$# $<
discoveryService: $(FRAMEWORK_OBJECTS) discoveryService.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/discoveryService.o $(FLAG_DICT_OBJECTS) $(CORE_FRAMEWORK_OBJECTS) $(NET_FRAMEWORK_OBJECTS) $(CONF_FRAMEWORK_OBJECTS)
Again, any and all help/suggestions will be greatly appreciated!

CMake compile-time defines

I am new to using CMake and am attempting to transfer our previous Makefiles into CMakeLists. I have one file, *dsplink_defines.txt* that has the following compile-time defines.
*-DOS_LINUX -DMAX_DSPS=1 -DMAX_PROCESSORS=2 -DID_GPP=1 -DOMAPL1XX -DPROC_COMPONENT -DPOOL_COMPONENT -DNOTIFY_COMPONENT -DMPCS_COMPONENT -DRINGIO_COMPONENT -DMPLIST_COMPONENT -DMSGQ_COMPONENT -DMSGQ_ZCPY_LINK -DCHNL_COMPONENT -DCHNL_ZCPY_LINK -DZCPY_LINK -DKFILE_DEFAULT -DDA8XXGEM -DDA8XXGEM_PHYINTERFACE=SHMEM_INTERFACE -DGPP_SWI_MODE -D_REENTRANT -DVERIFY_DATA -DDDSP_DEBUG*
Our previous Makefile took care of this in the following manner and took care of this by using shell cat starting on line 8:
BIN = ../../build/bin
TMP = build
BUILD_DEF = -DBUILD=$(BUILD_VERSION) -DBUILD_DATE=$(BUILD_DATE)
# these files are captured from the DSPLink Sample build directory (and the named changed)
# they contain the appropriate includes and flags to build a dsplink application.
DSPLINK_INCLUDES = $(shell cat ../dsplink_config/dsplink_includes.txt)
DSPLINK_FLAGS = $(shell cat ../dsplink_config/dsplink_flags.txt)
DSPLINK_DEFINES = $(shell cat ../dsplink_config/dsplink_defines.txt)
DSPLINK_LIBS = $(DSPLINK_PACKAGE_DIR)/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplink.lib
#Our project variables
INCLUDE = -I../framework -I../io_master -I../logging -I../../dsp/include - I../flagDictionary
#TOOLCHAIN = ${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/bin
TOOLCHAIN = /OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin
PLATFORM=armv5l-timesys-linux-uclibcgnueabi
#Compile Options
CC=$(TOOLCHAIN)/$(PLATFORM)-g++
LINKER=$(TOOLCHAIN)/$(PLATFORM)-g++
CFLAGS+= $(BUILD_DEF) $(INCLUDE) $(DSPLINK_DEFINES) $(DSPLINK_FLAGS) $(DSPLINK_INCLUDES)
DEBUG = -O
#list of things to compile.
FW_BUILD_DIR=../framework/build
LOG_BUILD_DIR=../logging/build
FLAG_DICT_BUILD_DIR=../flagDictionary/build
FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/com.o \
$(FW_BUILD_DIR)/application.o \
$(FW_BUILD_DIR)/memoryManagerBase.o \
$(FW_BUILD_DIR)/memoryManager.o \
$(FW_BUILD_DIR)/arguments.o \
$(FW_BUILD_DIR)/lockManager.o \
$(FW_BUILD_DIR)/controlCom.o \
$(FW_BUILD_DIR)/paths.o \
$(LOG_BUILD_DIR)/subsystemLogMasks.o \
$(LOG_BUILD_DIR)/logger.o
FLAG_DICT_OBJECTS= $(FLAG_DICT_BUILD_DIR)/flagEntry.o \
$(FLAG_DICT_BUILD_DIR)/flagDictionary.o
OBJECTS = spidev_test.o sysMon.o
EXES = sysMon
all: $(OBJECTS) $(EXES)
.c.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DEBUG) -o $(TMP)/$# $<
.cpp.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DEBUG) -o $(TMP)/$# $<
spidev_test: $(FRAMEWORK_OBJECTS) spidev_test.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/spidev_test.o $(FRAMEWORK_OBJECTS)
sysMon: $(FRAMEWORK_OBJECTS) sysMon.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/sysMon.o $(FLAG_DICT_OBJECTS) $(FRAMEWORK_OBJECTS)
deploy:
../../build/deploy
How do I pass these in using a CMakeList
This should work:
file(READ path/to/dsplink_defines.txt defines) #read file into variable 'defines'
string(REPLACE " " ";" defines "${defines}") #turn space separation into CMake list
add_definitions(${defines})
Of course, if you have full control of the file and can change its format to use semicolons for separation instead of spaces, you can do that and skip the string() line (probably speeding up your CMake processing a little bit by this).

Error generating dependencies with make

I am trying to implement the non-recursive make solution outlined in the paper "Recursive Make Considered Harmful". I'm currently stuck on getting the *.d dependency files to generate. I've provided the makefile, sample module.mk and error below. Any ideas how I can fix this?
MODULES := \
module1 \
module2
# define compiler
CC = /opt/local/bin/clang++-mp-3.1
# exclude the following warnings for clang
CLANG_NO_WARN = \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
# look for include files in each of the modules
CFLAGS += \
-g -Weverything -Wall -std=c++11 -stdlib=libc++ $(CLANG_NO_WARN) \
-I../ -I/usr/local/include $(patsubst %, -I%, $(MODULES))
# linker flags
LDFLAGS := \
-stdlib=libc++ \
-L/usr/local/boost_1_50_0/stage/lib -L/usr/local/lib
# extra libraries if required (each module will add to this)
LIBS := \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# source files to be compiled (each module will add to this)
SRCS := \
Main.cpp
# include the descriptions for each module
include $(patsubst %, %/module.mk, $(MODULES))
# determine the object files
OBJS := \
$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
prog: $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include the C include dependencies
include $(OBJS:.o=.d)
# calculate C include dependencies
%.d: %.cpp
depend.sh `dirname $*.cpp` $(CFLAGS) $*.cpp > $#
----------
#!/bin/sh
# Evaluate dependencies for use by the makefile
echo "Called"
DIR="$1"
shift 1
case "$DIR" in
"" | ".")
$CC -MM -MG "$#" | sed -e 's#ˆ\(.*\)\.o:#\1.d \1.o:#' ;;
*)
$CC -MM -MG "$#" | sed -e "s#ˆ\(.*\)\.o:#$DIR/\1.d \ $DIR/\1.o:#" ;;
esac
------------
# module.mk
SRCS += \
Algo.cpp \
CommandHandler.cpp \
Exchange.cpp \
TCPSocket.cpp \
TradingEngine.cpp
----------
$ make
makefile:68: Main.d: No such file or directory
makefile:68: view_string.d: No such file or directory
makefile:68: Algo.d: No such file or directory
makefile:68: CommandHandler.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: TCPSocket.d: No such file or directory
makefile:68: TradingEngine.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: Requests.d: No such file or directory
makefile:68: TickCapture.d: No such file or directory
makefile:68: types.d: No such file or directory
make: *** No rule to make target `types.d'. Stop.
UPDATE
Finished makefile and sample module.mk
$cat makefile
# executable name
BINARY := my_prog
# clang config
CLANG := /opt/local/bin/clang++-mp-3.1
CLANG_WARNINGS := \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
CLANG_CFLAGS := \
-g -Weverything -Wall -std=c++11 -stdlib=libc++
CLANG_LDFLAGS := \
-stdlib=libc++
# generic compiler config
CC := $(CLANG)
CFLAGS := $(CLANG_WARNINGS) $(CLANG_CFLAGS)
LDFLAGS := $(CLANG_LDFLAGS)
INCS := \
-I../ \
-I/usr/local/include \
$(patsubst %, -I%, $(SUBDIRS))
LIBS := \
-L/usr/local/boost_1_50_0/stage/lib \
-L/usr/local/lib \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# list subdirectories in which to look for dependencies
# must define SRCS first as subdirs will append to this
# their src files
SRCS := Main.cpp
SUBDIRS := \
module1 \
module2
include $(patsubst %, %/module.mk, $(SUBDIRS))
# derive object files from srcs
OBJS := $(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
$(BINARY): $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include generated dependency files
DEPS := $(OBJS:.o=.d)
-include $(DEPS)
# generate include dependencies
%.d: %.cpp
./depend.sh `dirname $*.cpp` $(INCS) $*.cpp > $#
# compile
.cpp.o:
$(CC) $(CFLAGS) $(INCS) $< -c -o $#
# clean, obviously
clean:
rm -f $(BINARY)
rm -f $(OBJS)
rm -f $(DEPS)
# et voila!
-----
$cat module1/module.mk
SRCS_PATH := module1
SRCS += \
$(SRCS_PATH)/Algo.cpp \
$(SRCS_PATH)/CommandHandler.cpp \
$(SRCS_PATH)/Exchange.cpp \
$(SRCS_PATH)/TCPSocket.cpp \
$(SRCS_PATH)/TradingEngine.cpp
It looks as if some module adds types.cpp to SRCS, even though no such source file exists.
As for the warnings, the first time you run this makefile, the dependency files (foo.d) do not yet exist, so Make complains that it can't include them. It's not a problem, and the warnings won't appear in subsequent runs when those files do exist beforehand. To supress the warnings entirely, change include to -include.