I need to compile a C++ project which is going to use external libraries and headers from the project for linear programming COIN-OR. It contains two .cpp files. The main file, main-farmer, depends on pm.h.
pm.h has all the include lines main-farmer needs to use to call in the COIN-OR functions. This is is the code of pm.h:
#include "ClpSimplex.hpp"
#include "CoinHelperFunctions.hpp"
#include "CoinTime.hpp"
#include "CoinBuild.hpp"
#include "CoinModel.hpp"
I have a makefile provided by my teacher and modified to fit my own needs, but whenever I try to compile the project by running my Makefile I get the same error:
In file included from main-farmer.cpp:5:0: pm.h:14:26: fatal error:
ClpSimplex.hpp: No such file or directory compilation terminated.
make: *** [main-farmer.o] Error 1
This is the Makefile:
#
P=farmer
#
EXE=$(P)
OBJS=main-farmer.o model-farmer.o param-farmer.o pm.h
ADDLIBS=-D.
ADDINCFLAGS=-I.
SRCDIR=~/coin-projects
##########
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion
CXXLINKFLAGS=-Wl,--rpath -Wl,/installed/CoinAll/lib
CC=gcc
CFLAGS=-03 -fomit-frame-pointer -pipe -DNDEBUG -pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall
COININCDIR=/installed/CoinAll/include/coin
# COIN-OR libs
COINLIBDIR=/installed/CoinAll/lib
# Clp
LIBS=-L$(COINLIBDIR) -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm \
`cat $(COINLIBDIR)/cgl_addlibs.txt` \
`cat $(COINLIBDIR)/clp_addlibs.txt` \
`cat $(COINLIBDIR)/coinutils_addlibs.txt`
CLEANFILES=\
addBits.o addBits \
addColumns.o addColumns \
addRows.o addRows \
decompose.o decompose \
defaults.o defaults \
driver2.o driver2 \
driver.o driver \
driverC.o driverC \
dualCuts.o dualCuts \
ekk.o ekk \
ekk_interface.o ekk_interface \
hello.o hello \
makeDual.o makeDual \
minimum.o minimum \
network.o network \
piece.o piece \
rowColumn.o rowColumn \
sprint2.o sprint2 \
sprint.o sprint \
testBarrier.o testBarrier \
testBasis.o testBasis \
testGub2.o testGub2 \
testGub.o testGub \
testQP.o testQP \
useVolume.o useVolume
# Part 3
#
all: $(EXE)
.SUFFIXES: .cpp .c .o .obj
$(EXE): $(OBJS)
bla=;
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $# $$bla $(ADDLIBS) $(LIBS)
####
########
############
########
####
clean:
rm -rf $(CLEANFILES)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
.c.o:
$(CC) $(CFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
.c.obj:
$(CC) $(CFLAGS) $(INCL) -c -o $# `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi`
Note: ClpSimplex.hpp lives in the directory specified as COININCDIR.
Your Makefile defines COININCDIR which probably points to the parent directory of your .hpp headers. Those need to be found by the compiler, and as the variable is not used, it explains why they are not found.
If you add -I$(COININCDIR) to CXXFLAGS, the compiler will be able to locate them.
Related
I am working on IMX7(Phytec zeta board) with yocto linux. On already working helloworld recipe(named as imx7-2110) I added some application source files(C, C++, h, hpp), created a make file and edited .bb files accordingly. on compilation I am getting error that one of the .hpp file(PktDriverAbstractionLayer.hpp) is not found, although it present in source directory and corresponding path is given to .bb file.
What could be the reason? I tried some suggestion available on internet forums but it didn't help.
Details of error are here:
[root#localhost build]# bitbake imx7-2110
Loading cache: 100% |###########################################| ETA:
00:00:00
Loaded 2800 entries from dependency cache.
Parsing recipes: 100% |#########################################| Time:
00:00:00
Parsing of 2223 .bb files complete (2222 cached, 1 parsed). 2799 targets,
220 skipped, 5 masked, 0 errors.
WARNING: No bb files matched BBFILE_PATTERN_phytec '^/opt/PHYTEC_BSPs
/yocto_imx7/sources/meta-phytec/common/'
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.30.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "CentOSLinux-7.4.1708"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "imx7d-phyboard-zeta-001"
DISTRO = "fsl-imx-x11"
DISTRO_VERSION = "4.1.15-2.0.1"
TUNE_FEATURES = "arm armv7ve vfp neon callconvention-hard
cortexa7"
TARGET_FPU = "hard"
meta
meta-yocto = "HEAD:f5da2a5913319ad6ac2141438ba1aa17576326ab"
meta-oe
meta-multimedia = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-fsl-arm = "HEAD:be78894e4682f111575470fb23e51e6ba523508d"
meta-fsl-arm-extra = "HEAD:3dfb82fc7e703eae9891b3ffda0e9393701f2396"
meta-fsl-demos = "HEAD:a165068f8a0d1cf29aabe4b4053f28be1c2aa492"
meta-bsp
meta-sdk = "HEAD:90399d99af8a2660ebe50b49752e95b210239fd9"
meta-browser = "HEAD:77736988073a5d90fcff9d0005c8477332ede387"
meta-gnome
meta-networking
meta-python
meta-filesystems = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-qt5 = "HEAD:ccae79be69c5268df3b47e4e14cea0591c39a531"
meta-phytec
meta-phytec-fsl = "HEAD:0b1de01225a2ec0debf71eb13be403baa9f4919f"
meta-imx7-2110 = "<unknown>:<unknown>"
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: imx7-2110-0.1-r0 do_compile: Function failed: do_compile (log file
is located at /opt/PHYTEC_BSPs/yocto_imx7/build/tmp/work/cortexa7hf-
neon-poky-linux-gnueabi/imx7-2110/0.1-r0/temp/log.do_compile.7235)
ERROR: Logfile of failure stored in: /opt/PHYTEC_BSPs/yocto_imx7/build
/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/imx7-2110/0.1-r0
/temp/log.do_compile.7235
Log data follows:
| DEBUG: Executing shell function do_compile
| arm-poky-linux-gnueabi-g++ -march=armv7ve -mfpu=neon -mfloat-abi=hard
-mcpu=cortex-a7 --sysroot=/opt/PHYTEC_BSPs/yocto_imx7/build/tmp/sysroots
/imx7d-phyboard-zeta-001 -c -pthread -std=c++11 -O2 -pipe -g
-feliminate-unused-debug-types -fdebug-prefix-map=/opt/PHYTEC_BSPs
/yocto_imx7/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/imx7-2110
/0.1-r0=/usr/src/debug/imx7-2110/0.1-r0 -fdebug-prefix-map=/opt
/PHYTEC_BSPs/yocto_imx7/build/tmp/sysroots/x86_64-linux= -fdebug-prefix-
map=/opt/PHYTEC_BSPs/yocto_imx7/build/tmp/sysroots/imx7d-phyboard-
zeta-001= -fvisibility-inlines-hidden -g -c -Wall -Wextra -pthread
-std=c++0x pcieman_client.cpp -o pcieman_client.o
| In file included from pcieman_client.cpp:45:0:
| PktDriverUDPManager.hpp:18:41: fatal error:
PktDriverAbstractionLayer.hpp: No such file or directory
| compilation terminated.
| make: *** [pcieman_client.o] Error 1
| WARNING: /opt/PHYTEC_BSPs/yocto_imx7/build/tmp/work/cortexa7hf-
neon-poky-linux-gnueabi/imx7-2110/0.1-r0/temp/run.do_compile.7235:1 exit 2
from 'make'
| ERROR: Function failed: do_compile (log file is located at
/opt/PHYTEC_BSPs/yocto_imx7/build/tmp/work/cortexa7hf-neon-poky-linux-
gnueabi/imx7-2110/0.1-r0/temp/log.do_compile.7235)
ERROR: Task 6 (/opt/PHYTEC_BSPs/yocto_imx7/sources/meta-imx7-2110/recipes-
example/example/imx7-2110_0.1.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 351 tasks of which 346 didn't need to be
rerun and 1 failed.
No currently running tasks (351 of 358)
Summary: 1 task failed:
/opt/PHYTEC_BSPs/yocto_imx7/sources/meta-imx7-2110/recipes-example
/example/imx7-2110_0.1.bb, do_compile
Summary: There was 1 WARNING message shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
[root#localhost build]#
Update with recipe:
#
# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.
#
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}
/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://build/build.tar.gz \
file://src/src.tar.gz \
file://include/include.tar.gz \
file://xpcie.h \
"
S = "${WORKDIR}"
#EXTRA_OEMAKE += "CPPFLAGS='-c -pthread -std=c++11'"
#EXTRA_OEMAKE += "CXXFLAGS='-g -c -Wall -Wextra -pthread -std=c++0x'"
do_compile() {
make
}
do_install() {
install -d ${D}${bindir}
install -m 0755 pcieman_client ${D}${bindir}
}
Here is also make with supplementary Info:
# Define Compiler to use
CC=g++
# Define default compiler options
# Flags passed to the preprocessor.
CPPFLAGS=-c -pthread -std=c++11
CXXFLAGS += -g -c -Wall -Wextra -pthread -std=c++0x
LFLAGS=-Bsymbolic
all: pcieman_client
pcieman_client: pcieman_client.o parser.o udp_socket_class.o
ds_api_class.o syn1588_class.o tr03_class.o pio_class.o search_api_class.o
packet_proc_class.o socket_tools.o crc_calc.o stdafx.o transaction_class.o
lpq_api_class.o fileIn_class.o vip_Rx_udp.o vip_Tx_udp.o
PktDriverAbstractionLayer.o PktDriverUDPManager.o StateMachine.o
MessageEvent.o appl_menu.o
$(CC) $(LFLAGS) -lpthread pcieman_client.o parser.o udp_socket_class.o
ds_api_class.o syn1588_class.o tr03_class.o pio_class.o search_api_class.o
packet_proc_class.o socket_tools.o crc_calc.o stdafx.o transaction_class.o
lpq_api_class.o fileIn_class.o vip_Rx_udp.o vip_Tx_udp.o
PktDriverAbstractionLayer.o PktDriverUDPManager.o StateMachine.o
appl_menu.o MessageEvent.o -o pcieman_client
pcieman_client.o: version.h udp_socket_class.h socket_tools.h
packet_proc_class.h transaction_class.h parser_params.h parser.h
pcieman_client.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) pcieman_client.cpp -o pcieman_client.o
udp_socket_class.o: udp_socket_class.h udp_socket_class.cpp
$(CC) $(CPPFLAGS) udp_socket_class.cpp -o udp_socket_class.o
appl_menu.o: appl_menu.hpp appl_menu.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) appl_menu.cpp -o appl_menu.o
ds_api_class.o: ds_api_class.h ds_api_class.cpp
$(CC) $(CPPFLAGS) ds_api_class.cpp -o ds_api_class.o
search_api_class.o: crc_calc.h search_api_class.h search_api_class.cpp
$(CC) $(CPPFLAGS) search_api_class.cpp -o search_api_class.o
pio_class.o: crc_calc.h pio_class.h pio_class.cpp
$(CC) $(CPPFLAGS) pio_class.cpp -o pio_class.o
syn1588_class.o: RxTx_settings.h syn1588_class.h syn1588_class.cpp
$(CC) $(CPPFLAGS) syn1588_class.cpp -o syn1588_class.o
tr03_class.o: RxTx_settings.h tr03_class.h tr03_class.cpp
$(CC) $(CPPFLAGS) tr03_class.cpp -o tr03_class.o
packet_proc_class.o: packet_proc_class.h packet_proc_class.cpp
$(CC) $(CPPFLAGS) packet_proc_class.cpp -o packet_proc_class.o
socket_tools.o: socket_tools.h socket_tools.cpp
$(CC) $(CPPFLAGS) socket_tools.cpp -o socket_tools.o
crc_calc.o: crc_calc.h crc_calc.cpp
$(CC) $(CPPFLAGS) crc_calc.cpp -o crc_calc.o
stdafx.o: stdafx.h stdafx.cpp
$(CC) $(CPPFLAGS) stdafx.cpp -o stdafx.o
transaction_class.o: packet_proc_class.h transaction_class.h
transaction_class.cpp
$(CC) $(CPPFLAGS) transaction_class.cpp -o transaction_class.o
lpq_api_class.o: lpq_api_class.h lpq_api_class.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) lpq_api_class.cpp -o lpq_api_class.o
fileIn_class.o: fileIn_class.h fileIn_class.cpp
$(CC) $(CPPFLAGS) fileIn_class.cpp -o fileIn_class.o
vip_Rx_udp.o: vip_Rx_settings.h RxTx_settings.h ds_api_class.h
syn1588_class.h tr03_class.h pio_class.h lpq_api_class.h
search_api_class.h PktDriverUDPManager.hpp vip_Rx_udp.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) vip_Rx_udp.cpp -o vip_Rx_udp.o
vip_Tx_udp.o: vip_Tx_settings.h RxTx_settings.h PktDriverUDPManager.hpp
vip_Tx_udp.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS)vip_Tx_udp.cpp -o vip_Tx_udp.o
parser.o: parser_params.h parser.h parser.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) parser.cpp -o parser.o
IGMPTimerManager.o: IGMPTimerManager.hpp IGMPTimerManager.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPTimerManager.cpp -o IGMPTimerManager.o
IGMPManager.o: IGMPManager.hpp IGMPManager.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPManager.cpp -o IGMPManager.o
IGMPNetworkManager.o: IGMPNetworkManager.hpp IGMPNetworkManager.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPNetworkManager.cpp -o
IGMPNetworkManager.o
IGMPHostEvent.o: IGMPHostEvent.hpp IGMPHostEvent.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPHostEvent.cpp -o IGMPHostEvent.o
IGMPMulticastHost.o: IGMPMulticastHost.hpp IGMPStateMachine.hpp
IGMPMulticastHost.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPMulticastHost.cpp -o
IGMPMulticastHost.o
StateMachine.o: StateMachine.hpp StateMachine.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) StateMachine.cpp -o StateMachine.o
MessageEvent.o: MessageEvent.hpp MessageEvent.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) MessageEvent.cpp -o MessageEvent.o
IGMPV2StateMachine.o: IGMPStateMachine.hpp IGMPV2StateMachine.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPV2StateMachine.cpp -o
IGMPV2StateMachine.o
IGMPV3StateMachine.o: IGMPStateMachine.hpp IGMPV3StateMachine.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPV3StateMachine.cpp -o
IGMPV3StateMachine.o
IGMPStateMachine.o: IGMPStateMachine.hpp IGMPStateMachine.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) IGMPStateMachine.cpp -o IGMPStateMachine.o
PktDriverAbstractionLayer.o: PktDriverAbstractionLayer.hpp
PktDriverAbstractionLayer.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) PktDriverAbstractionLayer.cpp -o
PktDriverAbstractionLayer.o
PktDriverUDPManager.o: PktDriverUDPManager.hpp PktDriverUDPManager.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) PktDriverUDPManager.cpp -o
PktDriverUDPManager.o
clean:
rm -rf *.o pcieman_client
configuration file local.conf is here:
MACHINE ??= 'imx7d-phyboard-zeta-001'
DISTRO ?= 'fsl-imx-x11'
PACKAGE_CLASSES ?= "package_rpm"
EXTRA_IMAGE_FEATURES = "debug-tweaks"
IMAGE_INSTALL_append=" xyzlayer"
IMAGE_INSTALL +="boost"
USER_CLASSES ?= "buildstats image-mklibs phytec-mirrors"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
STOPTASKS,/tmp,100M,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K \
ABORT,/tmp,10M,1K"
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
ASSUME_PROVIDED += "libsdl-native"
CONF_VERSION = "1"
BB_NUMBER_THREADS = "8"
PARALLEL_MAKE = "-j 4"
DL_DIR ?= "/opt/PHYTEC_BSPs/yocto_dl"
ACCEPT_FSL_EULA = "1"
bblayer file bblayers.conf is here:
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BSPDIR := "${#os.path.abspath(os.path.dirname(d.getVar('FILE', True)) +
'/../..')}"
BBFILES ?= ""
BBLAYERS = " \
${BSPDIR}/sources/poky/meta \
${BSPDIR}/sources/poky/meta-poky \
\
${BSPDIR}/sources/meta-openembedded/meta-oe \
${BSPDIR}/sources/meta-openembedded/meta-multimedia \
\
${BSPDIR}/sources/meta-fsl-arm \
${BSPDIR}/sources/meta-fsl-arm-extra \
${BSPDIR}/sources/meta-fsl-demos \
${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp \
${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk \
\
${BSPDIR}/sources/meta-browser \
${BSPDIR}/sources/meta-openembedded/meta-gnome \
${BSPDIR}/sources/meta-openembedded/meta-networking \
${BSPDIR}/sources/meta-openembedded/meta-python \
${BSPDIR}/sources/meta-openembedded/meta-filesystems \
${BSPDIR}/sources/meta-qt5 \
\
${BSPDIR}/sources/meta-phytec \
${BSPDIR}/sources/meta-phytec/meta-phytec-fsl \
${BSPDIR}/sources/meta-xyzlayer \
${BSPDIR}/sources/meta-testlayer \
"
What I see missing in the arm-poky-linux-gnueabi-g++ command line is the "-I" option for include path. Since the bitbake environment variables override the Makefile variables, it maybe required to explicitly specify the include paths using the following (in your recipe file before the do_compile() task):
TARGET_CFLAGS += " -I${S}"
Assuming that the header files are in the same folder as the source files.
The compiler in Qt Creator does not support c++11. So in my .pro file I added QMAKE_CXXFLAGS += -std=c++11
So my .pro file now looks like this:
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
server.cpp \
Section.cpp \
mainwindow.cpp \
main2.cpp \
client.cpp \
Chapter.cpp \
Book.cpp
HEADERS += \
Year.h \
Term.h \
Student.h \
Section.h \
mainwindow.h \
Load.h \
List.h \
Course.h \
ContentManager.h \
client.h \
Chapter.h \
Book.h
OTHER_FILES += \
Makefile \
D2.pro.user
This is my makefile:
#############################################################################
# Makefile for building: D2
# Generated by qmake (2.01a) (Qt 4.8.1) on: Mon Nov 10 23:00:21 2014
# Project: D2.pro
# Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile D2.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_WEBKIT
CFLAGS = -pipe -g -Wall -W $(DEFINES)
CXXFLAGS = -pipe -std=c++11 -g -Wall -W $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I.
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS)
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake-qt4
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = ./
####### Files
SOURCES = main.cpp \
server.cpp \
Section.cpp \
mainwindow.cpp \
main2.cpp \
client.cpp \
Chapter.cpp \
Book.cpp
OBJECTS = main.o \
server.o \
Section.o \
mainwindow.o \
main2.o \
client.o \
Chapter.o \
Book.o
DIST = /usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/common/gcc-base.conf \
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
/usr/share/qt4/mkspecs/common/g++-base.conf \
/usr/share/qt4/mkspecs/common/g++-unix.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/declarative_debug.prf \
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
D2.pro
QMAKE_TARGET = D2
DESTDIR =
TARGET = D2
first: all
####### Implicit rules
.SUFFIXES: .o .c .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$#" "$<"
####### Build rules
all: Makefile $(TARGET)
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
{ test -n "$(DESTDIR)" && DESTDIR="$(DESTDIR)" || DESTDIR=.; } && test $$(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $$DESTDIR" -ex quit '$(TARGET)' && test -f $(TARGET).gdb-index && objcopy --add-section '.gdb_index=$(TARGET).gdb-index' --set-section-flags '.gdb_index=readonly' '$(TARGET)' '$(TARGET)' && rm -f $(TARGET).gdb-index || true
Makefile: D2.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/common/gcc-base.conf \
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
/usr/share/qt4/mkspecs/common/g++-base.conf \
/usr/share/qt4/mkspecs/common/g++-unix.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/declarative_debug.prf \
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile D2.pro
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
/usr/share/qt4/mkspecs/common/gcc-base.conf:
/usr/share/qt4/mkspecs/common/gcc-base-unix.conf:
/usr/share/qt4/mkspecs/common/g++-base.conf:
/usr/share/qt4/mkspecs/common/g++-unix.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/debug.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/declarative_debug.prf:
/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/share/qt4/mkspecs/features/yacc.prf:
/usr/share/qt4/mkspecs/features/lex.prf:
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
qmake: FORCE
#$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile D2.pro
dist:
#$(CHK_DIR_EXISTS) .tmp/D21.0.0 || $(MKDIR) .tmp/D21.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/D21.0.0/ && (cd `dirname .tmp/D21.0.0` && $(TAR) D21.0.0.tar D21.0.0 && $(COMPRESS) D21.0.0.tar) && $(MOVE) `dirname .tmp/D21.0.0`/D21.0.0.tar.gz . && $(DEL_FILE) -r .tmp/D21.0.0
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
####### Sub-libraries
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile
check: first
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean:
####### Compile
main.o: main.cpp Course.h \
Year.h \
Term.h \
Student.h \
ContentManager.h \
Book.h \
List.h \
Chapter.h \
Section.h \
Load.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
server.o: server.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o server.o server.cpp
Section.o: Section.cpp Section.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Section.o Section.cpp
mainwindow.o: mainwindow.cpp mainwindow.h \
client.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
main2.o: main2.cpp mainwindow.h \
client.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main2.o main2.cpp
client.o: client.cpp client.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o client.o client.cpp
Chapter.o: Chapter.cpp Chapter.h \
List.h \
Section.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Chapter.o Chapter.cpp
Book.o: Book.cpp Book.h \
List.h \
Chapter.h \
Section.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Book.o Book.cpp
####### Install
install: FORCE
uninstall: FORCE
FORCE:
Unfortunately, I'm getting this error: [main.o] Error 1
This error was non-existent before adding c++11. I can't solve this problem. Can someone please help me here?
UPDATE:
Typing in gcc -v in the command line in Qt creator gave me:
Starting command 'gcc -v'
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
'gcc -v' finished
I think the compiler version is 4.6.3, which means it supports C++11
There's more to that error message than just [main.o] Error 1. Paste the whole error message.
However, some guesses as to your problem might include:
You use both $(OBJCOMP) and $(SUBLIBS) in your linker command, but neither of them is defined anywhere. Could this be the cause of the error?
Some old versions of g++ (for example, 4.6.3) spell the option -std=c++0x instead of -std=c++11. Depending on the output of g++ --version, you might need to use the older spelling.
You might need to add -std=c++11 to the LFLAGS as well as to the CXXFLAGS, to make sure that you're linking against the correct C++ library. (I don't know of any systems for which this matters, but I always try to get it right anyway.)
I got this error a few times as well.
I was frankly amazed at the lack of information in the error message, well, I mean, there is basically none.
Here is my interpretation of what the erro means:
main.o doesn't exist / can't be found / is entirely broken.
There are a few ways you could've ended up in this situation:
Location where main.o is supposed to be written is write protected. (You could try toggling shadowbuild in Qt creator)
You're out of space (I know, sounds absurd with 8TB HDDs on the market. This was what was happening for me tho.)
Your project is ill configured. (Sometimes there is a difference between / and \ in paths)
Your compiler is ill configured.
There is something very wrong with your code.
Unfortunately, I'm getting this error: [main.o] Error 1
.....
Believe me, that was the only error. I tried all your suggestions but none could solve the problem, unfortunately
Interestingly, Qt Creator does not remove your project's Makefile even if you do Cleaning and Rebuilding.
Those options does remove your output binary files (including .o files), but sometimes it can't be sufficient especially when you're editing the .pro file or .qrc file.
In most cases where the build error message is unclear and it's claimed, "Well it just worked before!" it's worth trying making sure that you're building it completely from the scratch all the way through by:
Going to your build directory such as:
../build-*
Deleting all relevant Makefile scripts and others if necessary,
Then re-building it again.
I am currently trying to build Face Tracker (by Jason Saragih) with "make" in my Windows 7 x64, but all I'm getting is: "No rule to make target src/lib/IO.o, needed by bin/face_tracker".
Does anyone have any idea of what is happening, please?
This is the makefile (also available in Jason Saragih's page):
# Paths
OPENCV_PATH=/OpenCV246/
# Programs
CC=
CXX=g++
# Flags
ARCH_FLAGS=-arch x86_64
CFLAGS=-Wextra -Wall -pedantic-errors $(ARCH_FLAGS) -O3
LDFLAGS=$(ARCH_FLAGS)
DEFINES=
INCLUDES=-I$(OPENCV_PATH)/include -Iinclude/
LIBRARIES=-L$(OPENCV_PATH)/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_objdetect
# Files which require compiling
SOURCE_FILES=\
src/lib/IO.cc\
src/lib/PDM.cc\
src/lib/Patch.cc\
src/lib/CLM.cc\
src/lib/FDet.cc\
src/lib/PAW.cc\
src/lib/FCheck.cc\
src/lib/Tracker.cc
# Source files which contain a int main(..) function
SOURCE_FILES_WITH_MAIN=src/exe/face_tracker.cc
# End Configuration
SOURCE_OBJECTS=$(patsubst %.cc,%.o,$(SOURCE_FILES))
ALL_OBJECTS=\
$(SOURCE_OBJECTS) \
$(patsubst %.cc,%.o,$(SOURCE_FILES_WITH_MAIN))
DEPENDENCY_FILES=\
$(patsubst %.o,%.d,$(ALL_OBJECTS))
all: bin/face_tracker
%.o: %.cc Makefile
## Make dependecy file
$(CXX) -MM -MT $# -MF $(patsubst %.cc,%.d,$<) $(CFLAGS) $(DEFINES) $(INCLUDES) $<
## Compile
$(CXX) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $# $<
-include $(DEPENDENCY_FILES)
bin/face_tracker: $(ALL_OBJECTS)
$(CXX) $(LDFLAGS) $(LIBRARIES) -o $# $(ALL_OBJECTS)
.PHONY: clean
clean:
#echo "Cleaning"
#for pattern in '*~' '*.o' '*.d' ; do \
find . -name "$$pattern" | xargs rm ; \
done
Thanks,
Fabio
How do I use different compiler flags for different source files in a Makefile? For example, I'd like a Makefile that will produce:
g++ -c -COMPILER_FLAGS_1 -g source1.cpp -o source1.o
g++ -c -COMPILER_FLAGS_2 -g source2.cpp -o source2.o
g++ -c -COMPILER_FLAGS_2 -g source3.cpp -o source3.o
g++ -c -COMPILER_FLAGS_2 -g source4.cpp -o source4.o
g++ -c -COMPILER_FLAGS_3 -g source5.cpp -o source5.o
g++ -c -COMPILER_FLAGS_3 -g source6.cpp -o source6.o
g++ -c -COMPILER_FLAGS_3 -g source7.cpp -o source7.o
g++ -g -o output source1.o source2.o source3.o source4.o source5.o source6.o source7.o
At the moment I've got about 20 source files (and that's expected to grow), so an easy to maintain file would be nice.
Thanks in advance.
You could do something like the following (untested, so the syntax might be slightly off):
OBJS_1 := source1.o
OBJS_2 := source2.o source3.o source4.o
OBJS_3 := source5.o source6.o source7.o
OBJS := $(OBJS_1) $(OBJS_2) $(OBJS_3)
output: $(OBJS)
$(CXX) -g -o $# $^
$(OBJS_1): CXXFLAGS := $(COMPILER_FLAGS_1)
$(OBJS_2): CXXFLAGS := $(COMPILER_FLAGS_2)
$(OBJS_3): CXXFLAGS := $(COMPILER_FLAGS_3)
$(OBJS): %.o: %.cpp
$(CXX) -c $(CXXFLAGS) -g $< -o $#
Here is UNIX/LINUX makefile which I wrote and tested on Solaris LINUX to handle different compilation flags for different sections of a GNUmakefile. Please let me know if it can be improved. Thank you
# GNUmakefile
#
# makefile for mdRightFielder
#
# Builds:
# libmdRightFielder.so or libmdRightFielder.sl
ifndef SUB
include ../header.mk
else
VPATH=../Source:../Source/PCRE:../Source/SQLite:../../cpswindows/Source:../../util/mdLicense
INCL=-I../Include -I../Include/PCRE -I../Include/SQLite -I../../cpswindows/Include -I ../../util -I../../util/mdLicense
APIOBJ=cGlobalDataDestructor.o cPCRE.o CppInterface.o cRightFielder-FillTokenGaps.o
PCREOBJ=pcre_chartables.o pcre_compile.o pcre_exec.o pcre_fullinfo.o pcre_get.o pcre_globals.o pcre_newline.o \
pcre_tables.o pcre_try_flipped.o
SQLITEOBJ=sqlite3.o
CPSWINDOWSOBJ=BinarySearch.o cConfigFile.o cCriticalSection.o cDateTime.o cException.o cFile.o cSQLite.o \
QuickSort.o StringFunctions.o
MDLICENSEOBJ=CBigNum.o mdLicense.o RSA.o
ifeq ($(CPU),sparc)
ifdef workshop
CALIGN=-xmemalign=1s
ifdef release
CXXALIGN=-Qoption cg -xmemalign=1s
else
CXXALIGN=-Qoption ccfe -y-xmemalign=1s
endif
endif
endif
COMPILER_FLAGS_1=-D_NO_GUI
COMPILER_FLAGS_2=-D_NO_GUI -DHAVE_CONFIG_H
CXXFLAGS+=-DPCRE_STATIC -DUSE_STATIC
CFLAGS+=-D_NO_GUI -DHAVE_CONFIG_H -DPCRE_STATIC -DUSE_STATIC
DEPFLAGS+=-DLINK_SIZE=2 -D_NO_GUI -DHAVE_CONFIG_H -DPCRE_STATIC -DUSE_STATIC
.PHONY: all clean
all: libmdRightFielder.so
cp -fp ../Include/mdRightFielder.h ../../util/mdEnums.h libmdRightFielder.so $(SHIP)
if [ `uname` = HP-UX ] ; \
then \
/bin/mv -f $(SHIP)/libmdRightFielder.so $(SHIP)/libmdRightFielder.sl ; \
fi
clean:
rm -f *.o *.so *.sl deps
rm -f core core.[0-9]*
$(APIOBJ): CXXFLAGS+=$(COMPILER_FLAGS_1)
$(PCREOBJ): CXXFLAGS+=$(COMPILER_FLAGS_2)
MARYOBJS = $(APIOBJ) $(PCREOBJ)
libmdRightFielder.so: \
$(MARYOBJS)
-$(CXX) $(CXXFLAGS) $(INCL) $(SHARED) $^ -o $# $(LDLIBS)
mary:
%.o : %.cpp # cancel implicit CPP compilation rule
%.o : %.cpp
$(CXX) $(CXXFLAGS) $(INCL) $(PIC) $< -o $# -c
%.o : %.c # cancel implicit C compilation rule
%.o : %.c
$(CC) $(CFLAGS) $(INCL) $(PIC) $< -o $# -c
endif
I started with a makefile that would generate the dependencies of my C++ files. It was a C++ project using google test. Later, I started a Qt project which uses qmake and links to a shared library which the old makefile builds. Needless to say, the old makefile is really complicated now.
I would like to make a qmake file which can do the following:
Build a shared library for a list a sources
Build google test (optionally, I would accept a separate makefile for this)
Build my Qt executable with a different list of sources linking to the first shared library
All builds should have debug and release versions which will output to different directories
Can someone point me in the right direction for making a *.pro file which will do that? I'm really not clear on how to do things like multiple targets in qmake.
Here is the current makefile I am using (clearly a mess):
GTEST_DIR = /home/matt/lib/gtest-1.5.0
GMOCK_DIR = /home/matt/lib/gmock-1.5.0
SRC_DIR = /home/matt/Documents/myproject
QTINC := -I/usr/share/qt4/mkspecs/linux-g++ -I/usr/include/qt4/QtCore \
-I/usr/include/qt4/QtGui -I/usr/include/qt4
TEST_SRCS = test/TestRunner.cpp test/CellTest.cpp test/PuzzleTest.cpp \
test/SingleCandidateMethodTest.cpp test/ExclusionMethodTest.cpp \
test/BlockIntersectionMethodTest.cpp test/CoveringSetMethodTest.cpp \
test/SimpleValidatorTest.cpp test/PuzzleMarkerTest.cpp \
test/PlayerValidatorTest.cpp test/SolverHelperTest.cpp \
test/GuessCommandTest.cpp test/MarkCommandTest.cpp \
test/UnmarkCommandTest.cpp test/MethodSolverTest.cpp \
test/SimplePuzzleImporterTest.cpp test/SolvedPuzzleImporterTest.cpp \
test/AddHintMarksCommandTest.cpp test/CellControllerTest.cpp \
test/PuzzleControllerTest.cpp
QT_SRCS =
LIB_SRCS = Puzzle.cpp Cell.cpp SingleCandidateMethod.cpp ExclusionMethod.cpp \
BlockIntersectionMethod.cpp CoveringSetMethod.cpp SimpleValidator.cpp \
PuzzleMarker.cpp PlayerValidator.cpp SolverHelper.cpp GuessCommand.cpp \
MarkCommand.cpp UnmarkCommand.cpp MethodSolver.cpp \
SimplePuzzleImporter.cpp SolvedPuzzleImporter.cpp GameManager.cpp \
CellController.cpp AddHintMarksCommand.cpp GameController.cpp \
PuzzleController.cpp
DEPDIR = .deps
df = $(DEPDIR)/$(#F)
# preprocessor
CPPFLAGS += -I$(GTEST_DIR)/include -I$(GMOCK_DIR)/include -I$(SRC_DIR) $(QTINC)
# C++ compiler
CXXFLAGS = -Wall -std=c++0x
# qt defines
QTDEF = -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
# stuff to link for Qt
QTFLAGS = -L/usr/lib -lQtCore -lQtGui -lpthread
# gtest headers, don't need to change
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
# gmock stuff, don't need to change
GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \
$(GMOCK_DIR)/include/gmock/internal/*.h \
$(GTEST_HEADERS)
MAKEDEPEND = $(CXX) $(CPPFLAGS) -MM -o $(df).d $<
MAKEDEPEND_TEST = $(CXX) $(CPPFLAGS) -MM -o $(df).d -MT $(basename $<).o $<
MAKEDEPEND_QT = $(CXX) $(CPPFLAGS) -MM -o $(df).d -MT $(basename $<).o $<
SRCS := main.cpp $(LIB_SRCS)
OBJS := $(SRCS:%.cpp=%.o)
LIB_OBJS := $(LIB_SRCS:%.cpp=%.o)
QT_OBJS := $(QT_SRCS:%.cpp=%.o)
TEST_OBJS := $(TEST_SRCS:%.cpp=%.o)
# targets:
debug : CXXFLAGS += -g -O0
# removed this warning because it sucks: -Wconversion (int to size_t!)
debug_warn : CXXFLAGS += -pedantic -Wextra
debug_warn : debug
debug : all
release : CXXFLAGS += -O2
release : all
lib : CXXFLAGS += -fPIC
lib : libSudokuLib.so
libSudokuLib.so : $(LIB_OBJS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o libSudokuLib.so $(LIB_OBJS)
all : sudoku run_tests
sudoku : $(OBJS) $(QT_OBJS)
$(CXX) $(CPPFLAGS) $(QTDEF) $(CXXFLAGS) $(QTFLAGS) $^ -o $#
run_tests : $(LIB_OBJS) $(TEST_OBJS) gtest.a gmock.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $#
# dependency stuff
.D_TARGET:
mkdir -p $(DEPDIR)
touch $#
.PRECIOUS: .D_TARGET
# GTEST building stuff don't touch me
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
GMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS)
gtest-all.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) -c \
$(GTEST_DIR)/src/gtest-all.cc
gmock-all.o : $(GMOCK_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \
-c $(GMOCK_DIR)/src/gmock-all.cc
gmock_main.o : $(GMOCK_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \
-c $(GMOCK_DIR)/src/gmock_main.cc
gmock.a : gmock-all.o gtest-all.o
$(AR) $(ARFLAGS) $# $^
gtest_main.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
$(GTEST_DIR)/src/gtest_main.cc
gtest.a : gtest-all.o
$(AR) $(ARFLAGS) $# $^
gtest_main.a : gtest-all.o gtest_main.o
$(AR) $(ARFLAGS) $# $^
# QT stuff
%Qt.o : %Qt.o .D_TARGET
$(MAKEDEPEND_QT);
#cp $(df).d $(df).P;
# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
# -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P;
#rm -f $(df).d
$(CXX) $(CPPFLAGS) $(QTDEF) $(CXXFLAGS) -o $# -c $<
# tests
%Test.o : %Test.cpp .D_TARGET $(GMOCK_HEADERS)
$(MAKEDEPEND_TEST);
#cp $(df).d $(df).P;
# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
# -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P;
#rm -f $(df).d
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $# -c $<
# objects from sources
%.o : %.cpp .D_TARGET
$(MAKEDEPEND);
#cp $(df).d $(df).P; \
# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
# -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P;
#rm -f $(df).d
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $# -c $<
-include $(QT_SRCS:%.cpp=$(DEPDIR)/%.o.P)
-include $(TEST_SRCS:test/%.cpp=$(DEPDIR)/%.o.P)
-include $(SRCS:%.cpp=$(DEPDIR)/%.o.P)
clean:
$(RM) $(OBJS) $(TEST_OBJS) $(QT_OBJS) \
gtest.a gtest_main.a gtest-all.o gtest_main.o \
.D_TARGET sudoku run_tests
rm -rf $(DEPDIR)
And here is the project.pro file for qmake (which relies on that first makefile instead of building the library itself)
TEMPLATE = app
TARGET = qtsudoku
DEPENDPATH += .
INCLUDEPATH += . ../myproject
CONFIG += qt warn_on debug
QMAKE_CXXFLAGS += -std=c++0x
LIBS += -L/home/matt/Documents/myproject -lSudokuLib
# Input
HEADERS += QtPuzzleModel.h QtPuzzleView.h QtGameApplication.h QtDirector.h \
QtMainWindow.h QtFactory.h
SOURCES += main.cpp QtPuzzleModel.cpp QtGameApplication.cpp QtDirector.cpp \
QtMainWindow.cpp QtFactory.cpp
In general, a good way to do something like this is with the SUBDIRS qmake template. You would make a qmake file for each of the items you want to build (shared library, google test, and the executable), then make a SUBDIRS template to do those in order. I think the subdirs template will provide the debug/release flags to each underlying make file.
For the shared library, the qmake library template should be fine.
I don't know about google test, I assume you could generate a qmake file for it if desired, or you could continue with the makefile.
For linking the two, you could make a qmake file that has a main.cpp, specifies the others as libraries, and builds an executable.
You can use DESTDIR, MOC_DIR, OBJECTS_DIR, and UI_DIR to change where generated files go.