As the title say i have a problem compiling so i have my makefile who compile great my .cpp , then I have .o in the bin directory but after that its off I stay with my .o files and nothing change ,
It seems it doesnt take into account the few lines i wrote after and cant have my .exe
I think its something to do with the last lines because all the compile thing from .cpp to .o works great
#--------------------------------------------------------------------------------------------------
#
# MAKEFILE of the Radio Simulation Program
#
#--------------------------------------------------------------------------------------------------
# 03/05/21 Creation
#--------------------------------------------------------------------------------------------------
# Define options and paths
CFLAGS = -Wall -O
SRCDIR = ./Src
INCDIR = ./Inc
BINDIR = ./Bin
TARGET = ./Bin
# Program name
EXE_PROG = $(BINDIR)/simradio.exe
all = $(EXE_PROG)
all: $(BINDIR)/SimMain.o $(BINDIR)/classConfigCtx.o $(BINDIR)/ClassRadMgr.o $(BINDIR)/GesCanSlot.o $(BINDIR)/GesCanSrv.o $(BINDIR)/SupSrv.o $(BINDIR)/AppliMsg.o $(BINDIR)/AgentSNMP.o
# Source file compilations
$(BINDIR)/SimMain.o: $(SRCDIR)/SimMain.cpp
g++ -o $(BINDIR)/SimMain.o -c $(SRCDIR)/SimMain.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/classConfigCtx.o: $(SRCDIR)/classConfigCtx.cpp
g++ -o $(BINDIR)/classConfigCtx.o -c $(SRCDIR)/classConfigCtx.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/ClassRadMgr.o: $(SRCDIR)/ClassRadMgr.cpp
g++ -o $(BINDIR)/ClassRadMgr.o -c $(SRCDIR)/ClassRadMgr.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/GesCanSlot.o: $(SRCDIR)/GesCanSlot.cpp
g++ -o $(BINDIR)/GesCanSlot.o -c $(SRCDIR)/GesCanSlot.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/GesCanSrv.o: $(SRCDIR)/GesCanSrv.cpp
g++ -o $(BINDIR)/GesCanSrv.o -c $(SRCDIR)/GesCanSrv.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/SupSrv.o: $(SRCDIR)/SupSrv.cpp
g++ -o $(BINDIR)/SupSrv.o -c $(SRCDIR)/SupSrv.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/AppliMsg.o: $(SRCDIR)/AppliMsg.cpp
g++ -o $(BINDIR)/AppliMsg.o -c $(SRCDIR)/AppliMsg.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/AgentSNMP.o: $(SRCDIR)/AgentSNMP.cpp
g++ -o $(BINDIR)/AgentSNMP.o -c $(SRCDIR)/AgentSNMP.cpp $(CFLAGS) -I$(INCDIR)
# Object files list
OBJ_LIST = $(BINDIR)/AgentSNMP.o $(BINDIR)/AppliMsg.o $(BINDIR)/classConfigCtx.o $(BINDIR)/ClassRadMgr.o $(BINDIR)/GesCanSlot.o $(BINDIR)/GesCanSrv.o $(BINDIR)/SupSrv.o $(BINDIR)/SimMain.o
help:
echo $(OBJ_LIST)
# Erase the former binary files
mrproper: clean
rm -f $(EXE_PROG):$(OBJ_LIST)
g++ -g -o $(EXE_PROG) $(OBJ_LIST)
Please see below code/reference example which will compile-link and generate the end executable.OFcourse, the dependency check can also be added in this
# Define options and paths
CFLAGS = -Wall -O
SRCDIR = ./Src
INCDIR = ./Inc
BINDIR = ./Bin
TARGET = ./Bin
# Program name
EXE_PROG = $(BINDIR)/simradio.exe
all: $(EXE_PROG)
# Source file compilations
$(BINDIR)/SimMain.o: $(SRCDIR)/SimMain.cpp
g++ -o $(BINDIR)/SimMain.o -c $(SRCDIR)/SimMain.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/classConfigCtx.o: $(SRCDIR)/classConfigCtx.cpp
g++ -o $(BINDIR)/classConfigCtx.o -c $(SRCDIR)/classConfigCtx.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/ClassRadMgr.o: $(SRCDIR)/ClassRadMgr.cpp
g++ -o $(BINDIR)/ClassRadMgr.o -c $(SRCDIR)/ClassRadMgr.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/GesCanSlot.o: $(SRCDIR)/GesCanSlot.cpp
g++ -o $(BINDIR)/GesCanSlot.o -c $(SRCDIR)/GesCanSlot.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/GesCanSrv.o: $(SRCDIR)/GesCanSrv.cpp
g++ -o $(BINDIR)/GesCanSrv.o -c $(SRCDIR)/GesCanSrv.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/SupSrv.o: $(SRCDIR)/SupSrv.cpp
g++ -o $(BINDIR)/SupSrv.o -c $(SRCDIR)/SupSrv.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/AppliMsg.o: $(SRCDIR)/AppliMsg.cpp
g++ -o $(BINDIR)/AppliMsg.o -c $(SRCDIR)/AppliMsg.cpp $(CFLAGS) -I$(INCDIR)
$(BINDIR)/AgentSNMP.o: $(SRCDIR)/AgentSNMP.cpp
g++ -o $(BINDIR)/AgentSNMP.o -c $(SRCDIR)/AgentSNMP.cpp $(CFLAGS) -I$(INCDIR)
# Object files list
OBJ_LIST = $(BINDIR)/AgentSNMP.o $(BINDIR)/AppliMsg.o $(BINDIR)/classConfigCtx.o $(BINDIR)/ClassRadMgr.o $(BINDIR)/GesCanSlot.o $(BINDIR)/GesCanSrv.o $(BINDIR)/SupSrv.o $(BINDIR)/SimMain.o
help:
echo $(OBJ_LIST)
$(EXE_PROG): $(OBJ_LIST)
g++ $(CFLAGS) $(OBJ_LIST) -o $#
echo "build successful"
I've looked at several similar posts reporting this error however, the majority seem to be related to running make in a different folder than that of the source files. In my case, the cpp files are in the same folder as my makefile from which I am running the make command. It seems my rule cannot locate 'AudioHandler.cpp' despite it being in the same folder as the makefile itself. I assume there is an error with a path somewhere, as this file is suspiciously the first one in the list! What am I doing wrong?
# compiler to use
CXX = g++
# header folder
IDIR = ../include
# compile flags
CXXFLAGS = -I$(IDIR) -Wall -std=c++0x `sdl2-config --cflags` `sdl2-config --libs` -lSDL_mixer
# output folder
ODIR = obj
# build folder
BDIR = ../build
# engine dependencies
_DEPS = AudioHandler.hpp Callback.hpp Entity.hpp Font.hpp Game.h GameMap.hpp GameMath.h InputHandler.hpp MapHandler.hpp Matrix3x3.hpp Matrix4x4.hpp Palette.hpp ScreenHandler.hpp Structs.h System.hpp Ticker.hpp Utilities.hpp Vec2.hpp Vec3d.hpp ZX_Palette.hpp Scene.h UpdateComponent.hpp vec2.hpp
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
# engine cpp directory
_OBJ = AudioHandler.o Callback.o Entity.o Font.o Game.o GameMap.o InputHandler.o MapHandler.o Matrix4x4.o Palette.o ScreenHandler.o System.o Ticker.o Utilities.o Vec2.o Vec3d.o ZX_Palette.o vec2.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.cpp $(DEPS)
$(CXX) -c -o $# $< $(CXXFLAGS)
$(BDIR)/libgameengine.a: $(OBJ)
ar rcs $# $^
I have a SConstruct that build my tool in 3 steps:
build a static library. In my case it's the antlr4 c++ runtime
generate the antlr4 cpp and h files (listener, visitor etc) of an antlr4's grammar
finally build a program using those files and linking to the antlr4 runtime library.
1 and 2 can be built in any order, even together but 3 ahs to be built when the other two have finished.
All this works perfectly when I don't use any VariantDir, however SCons fails when I try to use a variant directory, saying that it can't find the autogenerated files:
cons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
this is the whole SConstruct:
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
VariantDir('./build', './src')
VariantDir('./build/antlr4Runtime', './dependencies/antlr4Runtime')
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./build/antlr4Runtime/*.cpp') + \
Glob('./build/antlr4Runtime/atn/*.cpp') + \
Glob('./build/antlr4Runtime/dfa/*.cpp') + \
Glob('./build/antlr4Runtime/misc/*.cpp') + \
Glob('./build/antlr4Runtime/support/*.cpp') + \
Glob('./build/antlr4Runtime/tree/*.cpp') + \
Glob('./build/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./build/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './build/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./build/*.cpp') + Glob('./build/Parser/*.cpp'),
CPPPATH = ['./build', './build/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(auto_antlr_generated_files('./build/src/Parser/'), ParserFiles)
Depends(CoralLang, ParserFiles)
It is probably worth mentioning that at this point, when I have the error, the autogenerated antlr4 files are not in ./src nor in ./build, So basically the command never generated them in first place.
note that without VariantDir everything works as expected. Everything is build in the right steps without problems
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./dependencies/antlr4Runtime/*.cpp') + \
Glob('./dependencies/antlr4Runtime/atn/*.cpp') + \
Glob('./dependencies/antlr4Runtime/dfa/*.cpp') + \
Glob('./dependencies/antlr4Runtime/misc/*.cpp') + \
Glob('./dependencies/antlr4Runtime/support/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './dependencies/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./src/*.cpp') + Glob('./src/Parser/*.cpp'),
CPPPATH = ['./src', './dependencies/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(CoralLang, ParserFiles)
I have the feeling that I'm doing something remarkably silly but I can't figure out what exactly.
This is what SCons output with the first SConstruct, the one that uses VariantDir:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
scons: building terminated because of errors.
This is really all and if I read this correctly, SCons is jumping straight to point 3 and of course at it fails because point 2 didn't create the files that point 3 needs as source.
This is instead a snippet of the output of the second SConstruct, the one that doesn't use VariantDir. (I cut off some of the similar lines where Scons create the static library, but they are all similar, as you know)
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o dependencies/antlr4Runtime/ANTLRErrorListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/ANTLRErrorListener.cpp
...
clang++ -o dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.cpp
ar qc lib/libantlr4-runtime.a dependencies/antlr4Runtime/ANTLRErrorListener.o ... dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o
ranlib lib/libantlr4-runtime.a
java org.antlr.v4.Tool Coral.g4 -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser
clang++ -o src/Parser/CoralListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralListener.cpp
clang++ -o src/Parser/CoralBaseListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseListener.cpp
clang++ -o src/Parser/CoralParser.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralParser.cpp
clang++ -o src/Parser/CoralLexer.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralLexer.cpp
clang++ -o src/main.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/main.cpp
clang++ -o src/Parser/CoralVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralVisitor.cpp
clang++ -o src/Parser/CoralBaseVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseVisitor.cpp
clang++ -o coral src/main.o src/Parser/CoralBaseListener.o src/Parser/CoralBaseVisitor.o src/Parser/CoralLexer.o src/Parser/CoralListener.o src/Parser/CoralParser.o src/Parser/CoralVisitor.o -Llib -lantlr4-runtime
scons: done building targets.
So reading this is obvious that Scons start with building the static library, then he runs antlr to generate the files needed to parse my syntax and finally, when all the dependencies are created, it build the program.
I`m having a Project with some subdirectories. I want to compile them with one makefile per Directory and link all Output files into one executable. Can anyone explain me, which commands I should use (-c or -g or extra call)?
makefile in my root-directory:
LIBS =
# The test will be called in this file. There is no need to change this.
#SRCS = main_test.c
SRCS = min.c max.c
###############################################################################
# #
# Normally it is not needed to edited below this. #
# #
###############################################################################
#SRCS = main_test.c Automated.c Basic.c Console.c CUCurses.c CUError.c Cunit_intl.c \
# MyMem.c TestDB.c TestRun.c Util.c wxWidget.c main_test.c \
# $(TST_SRCS)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = out
#compile and link
#CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#compile without link
CFLAGS = -O0 -c -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
#VPATH=test
#VPATH=source
# define the executable file,
TARGET = CUnit
export COVERAGE = $(TST_SRCS)
export STUBS = $(STUB_SRCS)
all:
$(MAKE) -C stub
$(MAKE) -C source
#echo --- build finished ---
#echo.
#echo TODO
#echo --- start linking ---
#echo.
and makefile of subdirectory
# define any directories containing header files other than /usr/include
# TODO
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =
# TODO define the C source files
SRCS = $(COVERAGE)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = ../out
#compile without link
CFLAGS = -O0 -c -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
# define the executable file,
all: $(TARGET) $(OBJ)
$(CC) $(OBJ) $(CFLAGS) -o $(TARGET) $(LFLAGS) $(OBJ)
#echo +++ build of source finished +++
clean:
$(RM) *.o *~ $(MAIN)
# DO NOT DELETE THIS LINE -- make depend needs it
I it is easier for the linker, if all Output file are in the same Directory. Works this with ODIR?
With the compiler option -c -g I can compile each submake and link the object files together.
CFLAGS = -O0 -Wall -c -g -fmessage-length=0 -fprofile-arcs -ftest-coverage
I am trying to create a system of makefiles to build my whole project. I am using cygwin and gcc compiler. I am running into a linking error on shared libraries that I cannot figure out.
I am concerned with ld: cannot find -lbase and ld: cannot find -lsimsimA429.
These files were clearly built. I even did a directory listing as part of the build command to show that they exist.
-rwxr-xr-x+ 1 user group 116832 Mar 25 10:09 /cygdrive/d/myProj/lib/libbase.so
-rwxr-xr-x+ 1 user group 75972 Mar 25 10:09 /cygdrive/d/myProj/lib/libsimsima429.so
and the link command also shows that I am including the correct link directory
g++ -shared -L/cygdrive/d/myProj/lib -lpthread -lrt -lbase -lsimsimA429 ...
What am I doing wrong to incur this error?
Also, I am relatively new to writing makefiles. If you have any comments about how I could improve them, I would kindly appreciate a few comments.
Full makefiles and output are listed below...
/cygdrive/d/myProj/src/sfi/base/makefile
#------------------------------------------------------------------------------
#-- BASE
#------------------------------------------------------------------------------
#--
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
MKDIR=mkdir
ROOTDIR=$(realpath ../../..)
PROJDIR=$(notdir $(CURDIR))
LIBDIR=$(ROOTDIR)/lib
OBJDIR=$(ROOTDIR)/obj/$(PROJDIR)
SRCDIR=$(ROOTDIR)/src
#OUTPUT FILE lib file or executable
TARGET=$(LIBDIR)/lib$(PROJDIR).so
INCLUDES=
#INCLUDES+=
LIBS=
#LIBS+=
LDFLAGS=
LDFLAGS+= -shared
LDFLAGS+= -L$(LIBDIR)
#LDFLAGS+= -Wl,-rpath
CCFLAGS=
#CCFLAGS+= -fPIC
#CCFLAGS+= -ansi
#CCFLAGS+= -pedantic
CCFLAGS+= -g
CCFLAGS+= -Wall
#CCFLAGS+= -std=c++11
CCC=g++
SRC= $(call rwildcard,./,*.cpp)
OBJECTS=$(patsubst %.cpp,$(OBJDIR)/%.o,$(SRC))
# Set our own Goal.
.DEFAULT_GOAL := all
.PHONY: all
all: $(TARGET)
$(OBJDIR)/%.o: %.cpp
#$(MKDIR) -p $(abspath $(dir $#))
$(CCC) -c $(CCFLAGS) $(INCLUDES) $< -o $#
$(TARGET): $(OBJECTS)
$(CCC) $(LDFLAGS) $(LIBS) -o $(TARGET) $(OBJECTS)
ls -l $(TARGET)
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)
test:
#echo $(OBJECTS) | tr " " "\n"
/cygdrive/d/myProj/src/sfi/drivers/a429/simsimA429/makefile
#------------------------------------------------------------------------------
#-- SIMSIMA429
#------------------------------------------------------------------------------
#--
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
MKDIR=mkdir
ROOTDIR=$(realpath ../../../../..)
PROJDIR=$(notdir $(CURDIR))
LIBDIR=$(ROOTDIR)/lib
OBJDIR=$(ROOTDIR)/obj/$(PROJDIR)
SRCDIR=$(ROOTDIR)/src
#OUTPUT FILE lib file or executable
TARGET=$(LIBDIR)/lib$(PROJDIR).so
INCLUDES=
INCLUDES+= -I$(SRCDIR)/face
INCLUDES+= -I$(SRCDIR)/sfi/base
INCLUDES+= -I$(SRCDIR)/sfi/drivers/a429/include
LIBS=
LIBS+= -L$(LIBDIR)
#LIBS+= -lbase
LDFLAGS=
LDFLAGS+= -shared
#LDFLAGS+= -Wl,-rpath
CCFLAGS=
#CCFLAGS+= -fPIC
#CCFLAGS+= -ansi
#CCFLAGS+= -pedantic
CCFLAGS+= -g
CCFLAGS+= -Wall
#CCFLAGS+= -std=c++11
CCC=g++
SRC= $(call rwildcard,./,*.cpp)
OBJECTS=$(patsubst %.cpp,$(OBJDIR)/%.o,$(SRC))
# Set our own Goal.
.DEFAULT_GOAL := all
.PHONY: all
all: $(TARGET)
$(OBJDIR)/%.o: %.cpp
#$(MKDIR) -p $(abspath $(dir $#))
$(CCC) -c $(CCFLAGS) $(INCLUDES) $< -o $#
$(TARGET): $(OBJECTS)
$(CCC) $(LDFLAGS) $(LIBS) -o $(TARGET) $(OBJECTS)
ls -l $(TARGET)
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)
test:
#echo $(OBJECTS) | tr " " "\n"
/cygdrive/d/myProj/src/sfi/ioss/makefile
#------------------------------------------------------------------------------
#-- IOSS
#------------------------------------------------------------------------------
#--
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
MKDIR=mkdir
ROOTDIR=$(realpath ../../..)
PROJDIR=$(notdir $(CURDIR))
LIBDIR=$(ROOTDIR)/lib
OBJDIR=$(ROOTDIR)/obj/$(PROJDIR)
SRCDIR=$(ROOTDIR)/src
#OUTPUT FILE lib file or executable
TARGET=$(LIBDIR)/lib$(PROJDIR).so
INCLUDES=
INCLUDES+= -I$(SRCDIR)/face
INCLUDES+= -I$(SRCDIR)/sfi
INCLUDES+= -I$(SRCDIR)/sfi/base
INCLUDES+= -I$(SRCDIR)/sfi/drivers/a429/include
INCLUDES+= -I$(SRCDIR)/sfi/ioss
LIBS=
LIBS+= -L$(LIBDIR)
LIBS+= -lpthread
LIBS+= -lrt
LIBS+= -lbase
LIBS+= -lsimsima429
LDFLAGS=
LDFLAGS+= -shared
#LDFLAGS+= -Wl,-rpath
CCFLAGS=
#CCFLAGS+= -fPIC
#CCFLAGS+= -ansi
#CCFLAGS+= -pedantic
CCFLAGS+= -g
CCFLAGS+= -Wall
#CCFLAGS+= -std=c++11
CCC=g++
SRC= $(call rwildcard,./,*.cpp)
OBJECTS=$(patsubst %.cpp,$(OBJDIR)/%.o,$(SRC))
# Set our own Goal.
.DEFAULT_GOAL := all
.PHONY: all
all: $(TARGET)
$(OBJDIR)/%.o: %.cpp
#$(MKDIR) -p $(abspath $(dir $#))
$(CCC) -c $(CCFLAGS) $(INCLUDES) $< -o $#
$(TARGET): $(OBJECTS)
$(CCC) $(LDFLAGS) $(LIBS) -o $(TARGET) $(OBJECTS)
ls -l $(TARGET)
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)
test:
#echo $(OBJECTS) | tr " " "\n"
Full Output:
10:09:19 **** Build of configuration Default for project base ****
make -j all
g++ -c -g -Wall udpserver.cpp -o /cygdrive/d/myProj/obj/base/./udpserver.o
g++ -c -g -Wall udpclient.cpp -o /cygdrive/d/myProj/obj/base/./udpclient.o
g++ -c -g -Wall impl/clock.cpp -o /cygdrive/d/myProj/obj/base/./impl/clock.o
g++ -c -g -Wall impl/deque.cpp -o /cygdrive/d/myProj/obj/base/./impl/deque.o
g++ -c -g -Wall impl/thread.cpp -o /cygdrive/d/myProj/obj/base/./impl/thread.o
g++ -shared -L/cygdrive/d/myProj/lib -o /cygdrive/d/myProj/lib/libbase.so /cygdrive/d/myProj/obj/base/./udpserver.o /cygdrive/d/myProj/obj/base/./udpclient.o /cygdrive/d/myProj/obj/base/./impl/clock.o /cygdrive/d/myProj/obj/base/./impl/Stdafx.o /cygdrive/d/myProj/obj/base/./impl/deque.o /cygdrive/d/myProj/obj/base/./impl/thread.o
ls -l /cygdrive/d/myProj/lib/libbase.so
-rwxr-xr-x+ 1 user group 116832 Mar 25 10:09 /cygdrive/d/myProj/lib/libbase.so
10:09:25 Build Finished (took 5s.994ms)
10:09:25 **** Build of configuration Default for project simsimA429 ****
make all
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include A429HwCtrlTx.cpp -o /cygdrive/d/myProj/obj/simsima429/./A429HwCtrlTx.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include A429HwCtrlRx.cpp -o /cygdrive/d/myProj/obj/simsima429/./A429HwCtrlRx.o
g++ -shared -L/cygdrive/d/myProj/lib -o /cygdrive/d/myProj/lib/libsimsima429.so /cygdrive/d/myProj/obj/simsima429/./A429HwCtrlTx.o /cygdrive/d/myProj/obj/simsima429/./A429HwCtrlRx.o
ls -l /cygdrive/d/myProj/lib/libsimsima429.so
-rwxr-xr-x+ 1 user group 75972 Mar 25 10:09 /cygdrive/d/myProj/lib/libsimsima429.so
10:09:29 Build Finished (took 4s.339ms)
10:09:29 **** Build of configuration Default for project ioss ****
make -j all
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss IOS.cpp -o /cygdrive/d/myProj/obj/ioss/./IOS.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss message/IOSmsg.cpp -o /cygdrive/d/myProj/obj/ioss/./message/IOSmsg.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss message/MsgId.cpp -o /cygdrive/d/myProj/obj/ioss/./message/MsgId.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss message/IOSmsgA429.cpp -o /cygdrive/d/myProj/obj/ioss/./message/IOSmsgA429.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss interface/IOSInterfaceHandle.cpp -o /cygdrive/d/myProj/obj/ioss/./interface/IOSInterfaceHandle.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss interface/IOSInterface.cpp -o /cygdrive/d/myProj/obj/ioss/./interface/IOSInterface.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss interface/direct/IOSDirect_Interface.cpp -o /cygdrive/d/myProj/obj/ioss/./interface/direct/IOSDirect_Interface.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429MajorFrame.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MajorFrame.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429MsgRxControl.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgRxControl.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429BusTx.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429BusTx.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429MsgRegistry.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgRegistry.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429BusRx.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429BusRx.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429Message.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429Message.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/a429/A429MsgBuffer.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgBuffer.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss bus/m1553/M1553Connection.cpp -o /cygdrive/d/myProj/obj/ioss/./bus/m1553/M1553Connection.o
g++ -c -g -Wall -I/cygdrive/d/myProj/src/face -I/cygdrive/d/myProj/src/sfi -I/cygdrive/d/myProj/src/sfi/base -I/cygdrive/d/myProj/src/sfi/drivers/a429/include -I/cygdrive/d/myProj/src/sfi/ioss config/IOSConfig.cpp -o /cygdrive/d/myProj/obj/ioss/./config/IOSConfig.o
g++ -shared -L/cygdrive/d/myProj/lib -lpthread -lrt -lbase -lsimsima429 -o /cygdrive/d/myProj/lib/libioss.so /cygdrive/d/myProj/obj/ioss/./IOS.o /cygdrive/d/myProj/obj/ioss/./message/IOSmsg.o /cygdrive/d/myProj/obj/ioss/./message/MsgId.o /cygdrive/d/myProj/obj/ioss/./message/IOSmsgA429.o /cygdrive/d/myProj/obj/ioss/./interface/IOSInterfaceHandle.o /cygdrive/d/myProj/obj/ioss/./interface/IOSInterface.o /cygdrive/d/myProj/obj/ioss/./interface/direct/IOSDirect_Interface.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MajorFrame.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgRxControl.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429BusTx.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgRegistry.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429BusRx.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429Message.o /cygdrive/d/myProj/obj/ioss/./bus/a429/A429MsgBuffer.o /cygdrive/d/myProj/obj/ioss/./bus/m1553/M1553Connection.o /cygdrive/d/myProj/obj/ioss/./config/IOSConfig.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lbase
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lsimsima429
collect2: error: ld returned 1 exit status
makefile:61: recipe for target '/cygdrive/d/myProj/lib/libioss.so' failed
make: *** [/cygdrive/d/myProj/lib/libioss.so] Error 1
10:09:42 Build Finished (took 13s.205ms)
Cygwin shared libraries are *.dll files, not lib*.so files. I suppose your linker is struggling to find base.dll and simsimA429.dll.