I know this question has been asked a million times but I can't seem to figure this out.
I'm working with a Makefile written by someone else:
CC=g++
CFLAGS=-Wall -g -gdwarf-3 -std=c++0x -rdynamic #
JEMALLOC=deps/jemalloc-5.1.0
NNMSG=deps/nng-1.3.2
BOOST=deps/boost_1_67_0
CRYPTOPP=deps/crypto
SQLITE=deps/sqlite-autoconf-3290000/build
.SUFFIXES: .o .cpp .h
SRC_DIRS = ./ ./benchmarks/ ./client/ ./transport/ ./system/ ./statistics/ ./blockchain/ ./db/ ./smart_contracts/ ./data_structures
DEPS = -I. -I./benchmarks -I./client/ -I./transport -I./system -I./statistics -I./blockchain -I./smart_contracts -I./data_structures -I$(JEMALLOC)/include -I$(NNMSG)/include -I$(BOOST) -I$(CRYPTOPP) -I./db -I$(SQLITE)/include
CFLAGS += $(DEPS) -D NOGRAPHITE=1 -Werror -Wno-sizeof-pointer-memaccess
LDFLAGS = -Wall -L. -L$(NNMSG)/lib -L$(JEMALLOC)/lib -Wl,-rpath,$(JEMALLOC)/lib -pthread -gdwarf-3 -lrt -std=c++0x -L$(CRYPTOPP) -L$(SQLITE)/lib
LDFLAGS += $(CFLAGS)
LIBS = -lnng -lanl -ljemalloc -lcryptopp -lsqlite3 -ldl
DB_MAINS = ./client/client_main.cpp ./unit_tests/unit_main.cpp
CL_MAINS = ./system/main.cpp ./unit_tests/unit_main.cpp
UNIT_MAINS = ./system/main.cpp ./client/client_main.cpp
CPPS_DB = $(foreach dir,$(SRC_DIRS),$(filter-out $(DB_MAINS), $(wildcard $(dir)*.cpp)))
CPPS_CL = $(foreach dir,$(SRC_DIRS),$(filter-out $(CL_MAINS), $(wildcard $(dir)*.cpp)))
CPPS_UNIT = $(foreach dir,$(SRC_DIRS),$(filter-out $(UNIT_MAINS), $(wildcard $(dir)*.cpp)))
#CPPS = $(wildcard *.cpp)
OBJS_DB = $(addprefix obj/, $(notdir $(CPPS_DB:.cpp=.o)))
OBJS_CL = $(addprefix obj/, $(notdir $(CPPS_CL:.cpp=.o)))
OBJS_UNIT = $(addprefix obj/, $(notdir $(CPPS_UNIT:.cpp=.o)))
#NOGRAPHITE=1
all:rundb runcl
.PHONY: deps_db
deps:$(CPPS_DB)
$(CC) $(CFLAGS) -MM $^ > obj/deps
sed '/^[^ ]/s/^/obj\//g' obj/deps > obj/deps.tmp
mv obj/deps.tmp obj/deps
-include obj/deps
rundb : $(OBJS_DB)
$(CC) -static -o $# $^ $(LDFLAGS) $(LIBS)
./obj/%.o: transport/%.cpp
$(CC) -static -c $(CFLAGS) $(INCLUDE) $(LIBS) -o $# $<
./obj/%.o: benchmarks/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: blockchain/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: system/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: statistics/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: client/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: %.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: db/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: smart_contracts/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
runcl : $(OBJS_CL)
$(CC) -static -o $# $^ $(LDFLAGS) $(LIBS)
./obj/%.o: transport/%.cpp
$(CC) -static -c $(CFLAGS) $(INCLUDE) $(LIBS) -o $# $<
./obj/%.o: benchmarks/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: blockchain/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: system/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: statistics/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: client/%.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
./obj/%.o: %.cpp
$(CC) -c $(CFLAGS) $(INCLUDE) -o $# $<
.PHONY: clean
clean:
rm -f obj/*.o obj/.depend rundb runcl runsq unit_test
What I'm attempting to do is place a header only library crow_all.h into a my file system/client_thread.cpp. Its worth noting that the crow library has this path /deps/crow_all.h.
I've tried appending -lpthread -L$(BOOST)/libs -lboost_system the LDFLAGS flag but I still manage to get this error:
/mnt/d/programs/ExpoLab/ResilientDB/deps/boost_1_67_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
Furthermore, I think my compiler is picking up my system version of the boost library?? I only say that since when I use Make when inside a docker container, I get a different error:
/usr/bin/ld: cannot find -lboost_system
Any advice would be amazing.. this is pretty frustrating :(
Related
I am trying to create Makefile for my C++ project.
My main.cpp contains this custom includes:
#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
For compilation I use:
g++ -stdlib=libc++ -o app.cgi -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc -L/usr/local/mysql-connector-c++/lib64 main.cpp -lmysqlcppconn
Now I need to add
#include "tinyxml2/tinyxml2.hpp"
The most simple way is to create Makefile. I wrote:
CC = g++
CFLAGS = -Wall -g -std=c++11
INCLUDES = -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc
LDLIBS = -L/usr/local/mysql-connector-c++/lib64 -lmysqlcppconn
SRCS = main.cpp ./tinyxml2/tinyxml2.cpp
OBJS = $(SRCS:.cpp=.o)
MAIN = main.cgi
#
# The following part of the makefile is generic
#
.PHONY: depend clean
all: $(MAIN)
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS)
.PRECIOUS: %.o
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -cpp $< -o $#
clean:
$(RM) *.o *~ $(MAIN)
depend: $(SRCS)
makedepend $(INCLUDES) $^
I got error:
main.cpp:21:10: fatal error: 'mysql_connection.h' file not found
#include <mysql_connection.h>
How to add includes to every .o? tinyxml2 doesn't use MySQL connector so I shouldn't add -lmysqlcppconn. How to do it?
You could build the makefile step by step. Start with the build command and make it a makefile target (I removed -stdlib=libc++):
app.cgi: main.cpp
g++ -o app.cgi -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc -L/usr/local/mysql-connector-c++/lib64 main.cpp -lmysqlcppconn
Next you can extract most elements into variables and add compiler flags:
CXX = g++
CXXFLAGS = -Wall -g -std=c++11
MAIN = app.cgi
CPPFLAGS = -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc
SRCS = main.cpp
LDFLAGS = -L/usr/local/mysql-connector-c++/lib64
LDLIBS = -lmysqlcppconn
$(MAIN): $(SRCS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(MAIN) $(SRCS) $(LDFLAGS) $(LDLIBS)
Add a clean and an all target:
CXX = g++
CXXFLAGS = -Wall -g -std=c++11
MAIN = app.cgi
CPPFLAGS = -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc
SRCS = main.cpp
LDFLAGS = -L/usr/local/mysql-connector-c++/lib64
LDLIBS = -lmysqlcppconn
.PHONY: all clean
all: $(MAIN)
$(MAIN): $(SRCS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(MAIN) $(SRCS) $(LDFLAGS) $(LDLIBS)
clean:
$(RM) *.o *~ $(MAIN)
Split into compiler step (implicit makefile rule) and linker step:
CXX = g++
CXXFLAGS = -Wall -g -std=c++11
MAIN = app.cgi
CPPFLAGS = -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc
SRCS = main.cpp
OBJS = $(SRCS:.cpp=.o)
LDFLAGS = -L/usr/local/mysql-connector-c++/lib64
LDLIBS = -lmysqlcppconn
.PHONY: all clean
all: $(MAIN)
$(MAIN): $(OBJS)
$(CXX) -o $(MAIN) $(OBJS) $(LDFLAGS) $(LDLIBS)
clean:
$(RM) *.o *~ $(MAIN)
Finally add ./tinyxml2/tinyxml2.cpp:
CXX = g++
CXXFLAGS = -Wall -g -std=c++11
MAIN = app.cgi
CPPFLAGS = -I/usr/local/include -I/usr/local/mysql-connector-c++-8.0.21/include/jdbc
SRCS = main.cpp ./tinyxml2/tinyxml2.cpp
OBJS = $(SRCS:.cpp=.o)
LDFLAGS = -L/usr/local/mysql-connector-c++/lib64
LDLIBS = -lmysqlcppconn
.PHONY: all clean
all: $(MAIN)
$(MAIN): $(OBJS)
$(CXX) -o $(MAIN) $(OBJS) $(LDFLAGS) $(LDLIBS)
clean:
$(RM) *.o *~ $(MAIN)
1. My file structure is:
build/
include/
-Sort.h
src/
-Sort.cpp
-main.cpp
2. My Makefile:
C++ = g++
SRCPATH := ./src
BUILDPATH := ./build
SORTINCPATH := ./include
TARGET := $(BUILDPATH)/sort
CPPFLAGS := -c -g -Wall -O0
INCPATH := -I./ -I$(SORTINCPATH)
CPPFILES += $(wildcard $(SRCPATH)/*.cpp)
CFILES += $(wildcard $(SRCPATH)/*.c)
HEADFILES += $(wildcard $(SORTINCPATH)/*.h)
CPPOBJS += $(CPPFILES:.cpp=.o)
COBJS += $(CFILES:.c=.o)
.PHONY : all
all: $(TARGET)
$(TARGET): $(CPPOBJS) $(COBJS)
$(C++) $(CPPFLAGS) -o $# $(CPPOBJS) $(COBJS)
%.o : %.c $(HEADFILES)
$(C++) $(CPPFLAGS) $(INCPATH) $< -o $#
%.O : %.cpp $(HEADFILES)
$(C++) $(CPPFLAGS) $(INCPATH) $< -o $#
.PHONY : clean
clean:
-rm $(TARGET) $(COBJS) $(CPPOBJS)
3. Sort.h
sort.h
4. Sort.cpp
sort-1.cpp
sort-2.cpp
5. When I run make, it shows the following:
g++ -c -g -Wall -O0 -c -o src/Sort.o src/Sort.cpp
and says "src/Sort.cpp:3:18: fatal error: Sort.h: no such file or directory".
I hope you can help me find out where the problem is.
Thank you so much!
Hi im getting this error when trying to build poco with gcc at cygwin console, it is related with a recipe failed and im not sure how to solved this...
Here is the error code:
$ make
make -C /cygdrive/c/poco-1.4.6p4-all/Foundation
make[1]: Entering directory '/cygdrive/c/poco-1.4.6p4-all/Foundation'
** Compiling src/ArchiveStrategy.cpp (debug, shared)
g++ -Iinclude -I/cygdrive/c/poco-1.4.6p4-all/CppUnit/include -I/cygdrive/c/poco-1.4.6p4-all/Foundation/include -I/cygdrive/c/poco-1.4.6p4-all/XML/include -I/cygdrive/c/poco-1.4.6p4-all/Util/include -I/cygdrive/c/poco-1.4.6p4-all/Net/include -I/cygdrive/c/poco-1.4.6p4-all/Crypto/include -I/cygdrive/c/poco-1.4.6p4-all/NetSSL_OpenSSL/include -I/cygdrive/c/poco-1.4.6p4-all/Data/include -I/cygdrive/c/poco-1.4.6p4-all/Data/SQLite/include -I/cygdrive/c/poco-1.4.6p4-all/Data/ODBC/include -I/cygdrive/c/poco-1.4.6p4-all/Data/MySQL/include -I/cygdrive/c/poco-1.4.6p4-all/Zip/include -I/cygdrive/c/poco-1.4.6p4-all/PageCompiler/include -I/cygdrive/c/poco-1.4.6p4-all/PageCompiler/File2Page/include -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY -DPOCO_BUILD_HOST=PB00YCT7 -D_XOPEN_SOURCE=500 -g -D_DEBUG -c src/ArchiveStrategy.cpp -o /cygdrive/c/poco-1.4.6p4-all/Foundation/obj/CYGWIN/x86_64/debug_shared/ArchiveStrategy.o
Assembler messages:
Fatal error: can't create /cygdrive/c/poco-1.4.6p4-all/Foundation/obj/CYGWIN/x86_64/debug_shared/ArchiveStrategy.o: No such file or directory
/cygdrive/c/poco-1.4.6p4-all/build/rules/compile:53: recipe for target '/cygdrive/c/poco-1.4.6p4-all/Foundation/obj/CYGWIN/x86_64/debug_shared/ArchiveStrategy.o' failed
make[1]: *** [/cygdrive/c/poco-1.4.6p4-all/Foundation/obj/CYGWIN/x86_64/debug_shared/ArchiveStrategy.o] Error 1
make[1]: Leaving directory '/cygdrive/c/poco-1.4.6p4-all/Foundation'
Makefile:62: recipe for target 'Foundation-libexec' failed
make: *** [Foundation-libexec] Error 2
Here is the bunch of code that is close to the line 53 that is showed as error:
$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, shared)"
$(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $#
This may be easy to solve but i haven't figure it out in days because im not an expert on c++ and makefiles.
Update: Im still getting the same error, i will add the complete rule definitions file:
# $Id: //poco/1.4/build/rules/compile#1 $
#
# compile
#
# Compile rule definitions for makefiles
#
#
# Targets
#
.PHONY: all all_static all_shared all_debug all_release \
clean static_debug static_release shared_debug shared_release
all: $(DEFAULT_TARGET)
all_static: static_debug static_release
all_shared: shared_debug shared_release
all_debug: static_debug shared_debug
all_release: static_release shared_release
#
# Create directories if necessary
#
.PHONY: objdirs libdirs bindirs static_bindirs
objdirs: $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_SHARED) $(OBJPATH_DEBUG_SHARED)
libdirs: objdirs $(LIBPATH)
bindirs: objdirs $(BINPATH)
static_bindirs: objdirs $(BINPATH)/static
$(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_SHARED) $(OBJPATH_DEBUG_SHARED) $(LIBPATH) $(BINPATH) $(BINPATH)/static:
$(MKDIR) $#
#
# Rules for compiling
#
$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, static)"
$(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(STATICOPT_CXX) -c $< -o $#
$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(release, static)"
$(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(STATICOPT_CXX) -c $< -o $#
$(OBJPATH_DEBUG_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, static)"
$(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(STATICOPT_CC) -c $< -o $#
$(OBJPATH_RELEASE_STATIC)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d
#echo "** Compiling" $< "(release, static)"
$(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(STATICOPT_CC) -c $< -o $#
$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, shared)"
$(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $#
$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(release, shared)"
$(CXX) $(INCLUDE) $(CXXFLAGS) $(RELEASEOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $#
$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, shared)"
$(CC) $(INCLUDE) $(CFLAGS) $(DEBUGOPT_CC) $(SHAREDOPT_CC) -c $< -o $#
$(OBJPATH_RELEASE_SHARED)/%.o: $(SRCDIR)/%.c $(DEPPATH)/%.d
#echo "** Compiling" $< "(release, shared)"
$(CC) $(INCLUDE) $(CFLAGS) $(RELEASEOPT_CC) $(SHAREDOPT_CC) -c $< -o $#
#
# Rules for creating dependency information
#
$(DEPPATH)/%.d: $(SRCDIR)/%.cpp
#echo "** Creating dependency info for" $^
$(MKDIR) $(DEPPATH)
$(DEP) $(SRCDIR)/$(patsubst %.d,%.cpp,$(notdir $#)) $# $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CXXFLAGS)
$(DEPPATH)/%.d: $(SRCDIR)/%.c
#echo "** Creating dependency info for" $^
$(MKDIR) $(DEPPATH)
$(DEP) $(SRCDIR)/$(patsubst %.d,%.c,$(notdir $#)) $# $(OBJPATH_DEBUG_STATIC) $(OBJPATH_RELEASE_STATIC) $(OBJPATH_DEBUG_SHARED) $(OBJPATH_RELEASE_SHARED) $(INCLUDE) $(CFLAGS)
depend: $(addprefix $(DEPPATH)/,$(addsuffix .d,$(objects)))
I would say the problem is that the directory doesn't exist. The compiler won't create a directory that doesn't exist. Try modifying your rule to create the directory before invoking the compiler:
$(OBJPATH_DEBUG_SHARED)/%.o: $(SRCDIR)/%.cpp $(DEPPATH)/%.d
#echo "** Compiling" $< "(debug, shared)"
mkdir -p $(dir $#)
$(CXX) $(INCLUDE) $(CXXFLAGS) $(DEBUGOPT_CXX) $(SHAREDOPT_CXX) -c $< -o $#
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
Simply put: It's not finding the include paths:
CC = g++
OBJS = *.o #*/*.o
DEBUG = -g
PNAME = game
INCLUDES = -Iheaders
CFLAGS = -Wall $(DEBUG)
LFLAGS = -Wall -lsfml-graphics -lsfml-window -lsfml-system $(DEBUG)
all: build
build: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o $(PNAME)
clean:
\rm *.o *~ $(PNAME)
.cpp:
$(CC) $(CFLAGS) $(INCLUDES) -c $(.SOURCE)
Your makefile looks pretty broken to me. Firstly, you probably want:
OBJS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))
Secondly, your final rule needs to be something more like:
%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -c $^ -o $#