How to get better error messages in a MAKE? - c++

I run a make command on a CPP code. I get error messages like:
/home/itaymoav/dev/phpext/sitel/build/entities.cpp: In function ‘void googleset_free_storage(void*)’:
As can be seen, except showing me the entry point of the function with errors, it does not give me anymore data. Is there a flag or some other way to get proper error messages?
MakeFile -> I know it is big...
srcdir = /home/itaymoav/dev/phpext/build
builddir = /home/itaymoav/dev/phpext/build
top_srcdir = /home/itaymoav/dev/phpext/build
top_builddir = /home/itaymoav/dev/phpext/build
EGREP = /bin/grep -E
SED = /bin/sed
CONFIGURE_COMMAND = './configure' '--enable-entities'
CONFIGURE_OPTIONS = '--enable-entities'
SHLIB_SUFFIX_NAME = so
SHLIB_DL_SUFFIX_NAME = so
ZEND_EXT_TYPE = zend_extension
RE2C = exit 0;
AWK = gawk
ENTITIES_SHARED_LIBADD = -lstdc++
shared_objects_entities = entities.lo GoogleSet.lo
PHP_PECL_EXTENSION = entities
PHP_MODULES = $(phplibdir)/entities.la
PHP_ZEND_EX =
all_targets = $(PHP_MODULES) $(PHP_ZEND_EX)
install_targets = install-modules install-headers
prefix = /usr
exec_prefix = $(prefix)
libdir = ${exec_prefix}/lib
prefix = /usr
phplibdir = /home/itaymoav/dev/phpext/build/modules
phpincludedir = /usr/include/php5
CC = cc
CFLAGS = -g -O2
CFLAGS_CLEAN = $(CFLAGS)
CPP = cc -E
CPPFLAGS = -DHAVE_CONFIG_H
CXX = g++
CXXFLAGS = -g -O2
CXXFLAGS_CLEAN = $(CXXFLAGS)
EXTENSION_DIR = /usr/lib/php5/20090626+lfs
PHP_EXECUTABLE = /usr/bin/php
EXTRA_LDFLAGS =
EXTRA_LIBS =
INCLUDES = -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
LFLAGS =
LDFLAGS =
SHARED_LIBTOOL =
LIBTOOL = $(SHELL) $(top_builddir)/libtool
SHELL = /bin/bash
INSTALL_HEADERS =
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
all: $(all_targets)
#echo
#echo "Build complete."
#echo "Don't forget to run 'make test'."
#echo
build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $#
-#$(LIBTOOL) --silent --mode=install cp $# $(phptempdir)/$# >/dev/null 2>&1
libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $# && cp $# libs/libphp$(PHP_MAJOR_VERSION).so
install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
#echo "Installing PHP SAPI module: $(PHP_SAPI)"
-#$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-#if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
#$(INSTALL_IT)
install-modules: build-modules
#test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
#echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
#rm -f modules/*.la >/dev/null 2>&1
#$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
install-headers:
-#if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
src=$$i; \
fi; \
if test -f "$(top_srcdir)/$$src"; then \
$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
elif test -f "$(top_builddir)/$$src"; then \
$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
else \
(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
fi \
done; \
fi
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
PHP_TEST_SHARED_EXTENSIONS = ` \
if test "x$(PHP_MODULES)" != "x"; then \
for i in $(PHP_MODULES)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
done; \
fi; \
if test "x$(PHP_ZEND_EX)" != "x"; then \
for i in $(PHP_ZEND_EX)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \
done; \
fi`
PHP_DEPRECATED_DIRECTIVES_REGEX = '^(define_syslog_variables|register_(globals|long_arrays)?|safe_mode|magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
test: all
-#if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
clean:
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/*
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h sapi/apache/libphp$(PHP_MAJOR_VERSION).module buildmk.stamp
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
.PHONY: all clean install distclean test
.NOEXPORT:
entities.lo: /home/itaymoav/dev/phpext/build/entities.cpp
$(LIBTOOL) --mode=compile $(CXX) -I. -I/home/itaymoav/dev/phpext/build $(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -c /home/itaymoav/dev/phpext/build/entities.cpp -o entities.lo
GoogleSet.lo: /home/itaymoav/dev/phpext/build/GoogleSet.cpp
$(LIBTOOL) --mode=compile $(CXX) -I. -I/home/itaymoav/dev/phpext/build $(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -c /home/itaymoav/dev/phpext/build/GoogleSet.cpp -o GoogleSet.lo
$(phplibdir)/entities.la: ./entities.la
$(LIBTOOL) --mode=install cp ./entities.la $(phplibdir)
./entities.la: $(shared_objects_entities) $(ENTITIES_SHARED_DEPENDENCIES)
$(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $# -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_entities) $(ENTITIES_SHARED_LIBADD)

You will have to examine your Makefile and any rules files it includes. Find the rule for compiling .cpp into .o and see what sort of filtering it is doing on your compile output. If it is intentionally restricting the output of the compiler to make normal compiles less verbose it will probably have a flag you can set to override that. The Linux kernel (and many related Makefiles) use a QUIET flag for this purpose, so you can do make QUIET='' to disable the terse output and see everything.
If the build rule is hiding errors there is probably a bug in it. If you can find it and add it to your question someone may know how to fix it.

The line you quoted is not the real error message. It is just the first of two lines. The following line contains the really interesting stuff.
And only in the rare case that there isn't a second line should you worry. Because then somebody wrapped the compiler to suppress some of its error messages.

Related

make: *** No rule to make target `my_project.o', needed by `objects'. Stop

This is my makefile in linux
.SILENT:
.SUFFIXES: .cpp
FLAGS_CC = -c -fPIC -DUNIX -DLINUX -D_HNAREL_=500 -D_TARGET__REL=0 -D_TARGET__DEBUG=1 -D_ILS_MACROS -I$(cer_incl)
FLAGS_CPP = -c -Wno-deprecated -fPIC -frtti -finline-functions -DUNIX -DLINUX -D_HNAREL_=500 -D_TARGET__REL=0 -D_TARGET__DEBUG=1 -D_ILS_MACROS -I$(cer_incl)
FLAGS_LINK = -m32 -fPIC -lm -lc -lrt -lpthread -ldl
FLAGS_LINKSHR = -m32 -lm -lc -shared -Wl,-no-undefined -lrt -lpthread -ldl
CC = gcc $(FLAGS_CC) $(__define) $(__build)
CPP = g++ $(FLAGS_CPP) $(__define) $(__build)
LINK = g++ $(FLAGS_LINK)
LINKSHR = g++ $(FLAGS_LINKSHR)
PRINT = echo
##
## The following environment variables are defined for your convenience.
##-----
## __srcdir - Project directory that contains the makefile and source code.
## __objdir - Project subdirectory that stores objects for the given platform
## and target combination.
## __libdir - Public directory that contains objects and shareable libraries.
## __exedir - Public directory that contains executables.
##-----
## Please do not delete the following line!
###makefile###
###makedep###
#my_project.o
FLAGS__MY_PROJECT =
DEFINES__MY_PROJECT =
my_project.o: $(__objdir)/my_project.o
$(__objdir)/my_project.o: \
my_project.cpp \
$(cer_incl)/srvimpl.h \
$(PRINT) "compiling - my_project.cpp"
[[ -d $(__objdir) ]] || mkdir -p $(__objdir)
$(CPP) $(FLAGS__MY_PROJECT) $(DEFINES__MY_PROJECT) -o $(__objdir)/my_project.o my_project.cpp
#aps_s200061.o
FLAGS__APS_S200061 =
DEFINES__APS_S200061 =
aps_s200061.o: $(__objdir)/aps_s200061.o
$(__objdir)/aps_s200061.o: \
aps_s200061.cpp \
aps_s200061.h \
$(cer_incl)/srvimpl.h \
$(PRINT) "compiling - aps_s200061.cpp"
[[ -d $(__objdir) ]] || mkdir -p $(__objdir)
$(CPP) $(FLAGS__APS_S200061) $(DEFINES__APS_S200061) -o $(__objdir)/aps_s200061.o aps_s200061.cpp
###makedep###
FLAGS_CPP += -D__RHEL6
FLAGS__APS_S200061 =
objects: my_project.o aps_s200061.o
my_project : objects
$(PRINT) "creating - my_project "
$(LINKSHR) \
-Wl,--version-script=$(__srcdir)/my_project.emap \
-o $(__objdir)/my_project \
$(__objdir)/my_project.o \
$(__objdir)/aps_s200061.o \
-Wl,--start-group \
-L$(__libdir) -lapsobj -lcernobj -lcontainerobj -lstringobj -li18n_common -lmsgutilobj -lmftmiscobj -lsrvcoreobj -lcrmobj -lthreadobj \
-Wl,--whole-archive -lsrvobj -Wl,--no-whole-archive \
-Wl,--end-group \
-L$(__exedir) -ldb -ldps -lsrv -lsec \
-lcclora -lreg -lmsgapi -ldate \
-llogical -lsrvcore -lcrm
copy:
$(PRINT) "copying - my_project"
cp $(__objdir)/my_project $(__exedir)
it: my_project copy
# shr:my_project
I want to remove the command cp $(__objdir)/my_project $(__exedir) from the above file.
When I try removing the line manually in a text editor and save it , the make file doesn't throw any errors.
But if I try removing the line programmatically , we get make: *** No rule to make target my_project.o', needed by objects'. Stop.
Sequence of commands we use is :
'makedep'
'make -f ${PWD##*/}.linux -r __target=rel _define="-D_TARGET=_TARGET__REL " __srcdir=$PWD __objdir=$PWD/linuxx86-64 __libdir=$abc_lib_rel __exedir=$abc_exe_rel __build="-O3" it'

/usr/bin/ld: cannot find : No such file or directory - caused by makefile error

Good day.
I am attempting to compile a vulnerable vsftpd version for a University assignment. I'm having troubling compiling the source code onto the lxc container launched to host the vulnerable ftp server. The following message is spat at me when I attempt to execute the make command:
/usr/bin/ld: cannot find : No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:24: vsftpd] Error 1
Despite my many years writing code I am quite new to C++ in general, however I gather this might have something to do with line 24 of the Makefile, which is highlighted below:
# Makefile for systems with GNU tools
CC = gcc
INSTALL = install
IFLAGS = -idirafter dummyinc
#CFLAGS = -g
CFLAGS = -O2 -Wall -W -Wshadow #-pedantic -Werror -Wconversion
LIBS = `./vsf_findlibs.sh`
LINK = -Wl,-s, -lcrypt
OBJS = main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o \
tunables.o ftpdataio.o secbuf.o ls.o \
postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o \
banner.o filestr.o parseconf.o secutil.o \
ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o \
tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o \
ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o
.c.o:
$(CC) -c $*.c $(CFLAGS) $(IFLAGS)
vsftpd: $(OBJS)
24th line >>>> $(CC) -o vsftpd $(OBJS) $(LINK) $(LIBS) $(LDFLAGS)
install:
if [ -x /usr/local/sbin ]; then \
$(INSTALL) -m 755 vsftpd /usr/local/sbin/vsftpd; \
else \
$(INSTALL) -m 755 vsftpd /usr/sbin/vsftpd; fi
if [ -x /usr/local/man ]; then \
$(INSTALL) -m 644 vsftpd.8 /usr/local/man/man8/vsftpd.8; \
$(INSTALL) -m 644 vsftpd.conf.5 /usr/local/man/man5/vsftpd.conf.5; \
elif [ -x /usr/share/man ]; then \
$(INSTALL) -m 644 vsftpd.8 /usr/share/man/man8/vsftpd.8; \
$(INSTALL) -m 644 vsftpd.conf.5 /usr/share/man/man5/vsftpd.conf.5; \
else \
$(INSTALL) -m 644 vsftpd.8 /usr/man/man8/vsftpd.8; \
$(INSTALL) -m 644 vsftpd.conf.5 /usr/man/man5/vsftpd.conf.5; fi
if [ -x /etc/xinetd.d ]; then \
$(INSTALL) -m 644 xinetd.d/vsftpd /etc/xinetd.d/vsftpd; fi
clean:
rm -f *.o *.swp vsftpd
Despite my researching I do not understand how to resolve this.
Thanks in advance.
Installing the libmysqlclient should resolve this issue. On Ubuntu, run:
sudo apt-get install libmysqlclient-dev

No moc file is generated by make

I try to compile a qt cpp file but no moc is generated for Q_OBJECT objects. I am using Maya's distribution of qt. My makefile.qt file looks like this and I am compiling with make -f makefile.qt myPlugIn.bundle:
%.mak : %.pro qtconfig
$(QMAKE) -o - QMAKE_CC=$(CC) QMAKE_CXX=$(C++) $< | \
sed -e '/^TARGET.*=/s?=.*$$?= $$(QMAKE_TARGET).$(EXT)?' \
-e 's?-framework QtCore?$$(MAYA_LOCATION)/MacOS/QtCore?' \
-e 's?-framework QtGui?$$(MAYA_LOCATION)/MacOS/QtGui?' \
-e 's?-framework QtOpenGL?$$(MAYA_LOCATION)/MacOS/QtOpenGL?' \
-e 's?-framework QtTest?$$(MAYA_LOCATION)/MacOS/QtTest?' \
-e 's?-framework QtXml?$$(MAYA_LOCATION)/MacOS/QtXml?' \
-e 's?-dynamiclib??' -e 's?-mtune=generic??' >$#
PLUGINS = helixQtCmd.$(EXT) \
qtForms.$(EXT) \
saveSwatchesCmd.$(EXT)
ifeq ($(QMAKE),)
all:
#echo "Qt not found. Qt-based plug-ins will not be built."
else
all: $(PLUGINS)
endif
# For each plugin, make sure that its individual Makefile is up-to-date then
# use that Makefile to build the plugin.
.PHONY: force
%.$(EXT): force
$(MAKE) -f Makefile.qt $(#:.$(EXT)=.mak)
$(MAKE) -f $(#:.$(EXT)=.mak) $#
clean:
rm -f $(PLUGINS:.$(EXT)=.o) $(PLUGINS:.$(EXT)=.mak) \
moc_* ui_* qrc_*
Clean: clean
rm -f $(PLUGINS)
What command am I missing to generate this moc file ?
I finally added the following moc line:
%.$(EXT): force
moc $(#:.$(EXT)=.h) -o moc_$(#:.$(EXT)=.cpp)
$(MAKE) -f Makefile.qt $(#:.$(EXT)=.mak)
$(MAKE) -f $(#:.$(EXT)=.mak) $#

Receiving main.o error

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.

Makefile error in Pythia

When I use the Makefile in the examples folder of Pythia8185 I get an error (ME below!):
ME: This is mymain.cc
#include "Pythia8/Pythia.h" // Include Pythia headers.
using namespace Pythia8; // Let Pythia8:: be implicit.
int main() { // Begin main program.
// Set up generation.
Pythia pythia; // Declare Pythia object
pythia.readString("Top:gg2ttbar = on"); // Switch on process.
pythia.readString("Beams:eCM = 7000."); // 7 TeV CM energy.
pythia.init(); // Initialize; incoming pp beams is default.
// Generate event(s).
pythia.next(); // Generate an(other) event. Fill event record.
return 0;
} // End main program with error-free return.
This is the Makefile before edit:
#
# Examples Makefile.
#
# M. Kirsanov 07.04.2006
# Modified 18.11.2006
# 26.03.2008 CLHEP dependency removed
SHELL = /bin/sh
-include config.mk
ifeq (x$(PYTHIA8LOCATION),x)
PYTHIA8LOCATION=..
endif
-include $(PYTHIA8LOCATION)/config.mk
# Location of directories.
TOPDIR=$(shell \pwd)
INCDIR=include
SRCDIR=src
LIBDIR=lib
LIBDIRARCH=lib/archive
BINDIR=bin
# Libraries to include if GZIP support is enabled
ifeq (x$(ENABLEGZIP),xyes)
LIBGZIP=-L$(BOOSTLIBLOCATION) -lboost_iostreams -L$(ZLIBLOCATION) -lz
endif
# There is no default behaviour, so remind user.
all:
#echo "Usage: for NN = example number: make mainNN"
# Create an executable for one of the normal test programs
main00 main01 main02 main03 main04 main05 main06 main07 main08 main09 main10 \
main11 main12 main13 main14 main15 main16 main17 main18 main19 main20 \
main21 main22 main23 main24 main25 main26 main27 main28 main29 main30 \
main31 main32 main33 main34 main35 main36 main37 main38 main39 main40 \
main80: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable linked to HepMC (if all goes well).
# Owing to excessive warning output -Wshadow is not used for HepMC.
ifneq (x$(HEPMCLOCATION),x)
main41 main42: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -Wno-shadow -I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
$#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP) \
-lpythia8tohepmc \
-L$(HEPMCLOCATION)/lib -lHepMC
#ln -fs $(BINDIR)/$#.exe $#.exe
else
main41 main42:
#echo ERROR, this target needs HepMC, variable HEPMCLOCATION
endif
# Create an executable that links to LHAPDF
main51 main52 main53 main54: $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 $(LIBGZIP) \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
$(FLIBS)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable that links to LHAPDF and HepMC
main61 main62 main85 main86 main87 main88: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -Wno-shadow -I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
$#.cc -o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -lpythia8tohepmc $(LIBGZIP) \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
-L$(HEPMCLOCATION)/lib -lHepMC \
$(FLIBS)
#ln -fs $(BINDIR)/$#.exe $#.exe
# Create an executable that links to Fastjet
# Owing to excessive warning output -Wshadow is not used for Fastjet.
# (Fixed as of Fastjet 3.0.1, so will be modified eventually.)
ifneq (x$(FASTJETLOCATION),x)
main71 main72: $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a
#mkdir -p $(BINDIR)
# Note: $(CXXFLAGS) is after Fastjet flags as Fastjet includes
# optimisation/debug flags which may be unwanted (e.g. -g -O2)
$(CXX) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc \
`$(FASTJETLOCATION)/bin/fastjet-config --cxxflags --plugins` \
$(CXXFLAGS) -Wno-shadow \
-o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 -llhapdfdummy $(LIBGZIP) \
-L$(FASTJETLOCATION)/lib \
`$(FASTJETLOCATION)/bin/fastjet-config --libs --plugins`
#ln -fs $(BINDIR)/$#.exe $#.exe
#rm -f $#.o
else
main71 main72:
#echo ERROR, this target needs Fastjet, variable FASTJETLOCATION
endif
# Create an executable that links to Fastjet, HepMC and LHApdf
# Owing to excessive warning output -Wshadow is not used for Fastjet.
# (Fixed as of Fastjet 3.0.1, so will be modified eventually.)
ifneq (x$(FASTJETLOCATION),x)
main81 main82 main83 main84: \
$(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8.a $(PYTHIA8LOCATION)/$(LIBDIRARCH)/libpythia8tohepmc.a
#mkdir -p $(BINDIR)
# Note: $(CXXFLAGS) is after Fastjet flags as Fastjet includes
# optimisation/debug flags which may be unwanted (e.g. -g -O2)
$(CXX) -I$(PYTHIA8LOCATION)/$(INCDIR) $#.cc \
`$(FASTJETLOCATION)/bin/fastjet-config --cxxflags --plugins` \
$(CXXFLAGS) -Wno-shadow \
-I$(PYTHIA8LOCATION)/$(INCDIR) -I$(HEPMCLOCATION)/include \
-o $(BINDIR)/$#.exe \
-L$(PYTHIA8LOCATION)/$(LIBDIRARCH) -lpythia8 \
-L$(LHAPDFLOCATION) $(LHAPDFLIBNAME) \
-lpythia8tohepmc \
-L$(HEPMCLOCATION)/lib -lHepMC \
-L$(FASTJETLOCATION)/lib \
-L$(LHAPDFLOCATION)/lib \
`$(FASTJETLOCATION)/bin/fastjet-config --libs --plugins`
#ln -fs $(BINDIR)/$#.exe $#.exe
#rm -f $#.o
else
main81 main82 main83 main84:
#echo ERROR, this target needs Fastjet, variable FASTJETLOCATION
endif
# Clean up: remove executables and outdated files.
.PHONY: clean
clean:
rm -rf $(BINDIR)
rm -rf *.exe
rm -f *~; rm -f \#*; rm -f core*
After edit I add mymain: just after main80 and then I write make mymain and get the error as follows:
I edit the Makefile and add mymain to the list:
# Create an executable for one of the normal test programs
main00 main01 main02 main03 main04 main05 main06 main07 main08 main09 main10 \
main11 main12 main13 main14 main15 main16 main17 main18 main19 main20 \
main21 main22 main23 main24 main25 main26 main27 main28 main29 main30 \
main31 main32 main33 main34 main35 main36 main37 main38 main39 main40 \
main80 mymain: \
as suggested in the worksheet example page 4.
Then when I write make mymain in the Terminal I get the following error:
*** No rule to make target `../lib/archive/libpythia8.a', needed by `mymain'. Stop.
It should be noted that everything worked fine yesterday, I really don't know how to proceed. I deleted all pythia folders and untarred them again but the problem remains. Anyone know what the solution might be? I'm on a MacBook.
Is there a way to uninstall something like pythia completely and reinstall it? It seems some file in some cache is the problem