When running make I have the following compilation error:
/bin/sh: 1: /installed/CoinAll/include/coin: Permission denied
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`
INCL=-I`$(CYGPATH_W)$(COININCDIR)`$(ADDINCFLAGS)
CYGPATH_W=
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`
I have set the permissions as rwx for /installed/CoinAll/include/coin and for all of its files.
Thanks.
It seems to me as if the Makefile is trying to execute the program /installed/CoinAll/include/coin which instead is a directory. It does not matter how you chmod a directory, it will still not be possible to execute as a program.
The following line:
INCL=-I$(CYGPATH_W)$(COININCDIR)$(ADDINCFLAGS)
in combination with lines like this:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $# `test -f '$<' || echo '$(SRCDIR)/'`$<
... will evaluate to commands like:
g++ (a lot of c++-flags) -I`installed/CoinAll/include/coin` -c -o...
as both $(CYGPATH_W) and $(ADDINCFLAGS) are empty.
When the shell executes a command containing backticks "`"it will replace the text between the backticks with the output from the command between the backticks. Try this:
echo `ls /`
I had this error and it was my anti-virus. Turned on, I get the same error you do. Off, it works just fine. Then turning the anti-virus back on, same error as you get. It was my anti-virus so try turning all it's features off temporarily.
Related
I am trying to use the makefile for my work related to SPheno. I am on macOS. When I try to use the command "make Model=Scotogenic". it's showing "*** missing separator". I went through lot of forums and added tabs. when I tried to do it again , now it's showing "*** commands commence before first target" . I am using the default textedit in macOS. I am attaching both the code and screenshot. The terminal screenshot
Code:
# PreDef = -DGENERATIONMIXING -DONLYDOUBLE -DSEESAWIII
PreDef = -DGENERATIONMIXING -DONLYDOUBLE
# setting various paths
InDir = ../include
Mdir = ${InDir}
name = ../lib/libSPheno.a
#
# options for various compilers
#
# Intels ifort, default in optimized mode
F90 = ifort
comp = -c -O -module ${Mdir} -I${InDir}
LFlagsB = -O
# Intels ifort, debug modus
ifeq (${F90},ifortg)
F90 = ifort
comp = -c -g -module ${Mdir} -I${InDir}
LFlagsB = -g
endif
gfortran
ifeq (${F90},gfortran)
comp = -c -O -J${Mdir} -I${InDir}
LFlagsB = -O
endif
# g95
ifeq (${F90},g95)
comp = -c -O -fmod=${Mdir} -I${InDir}
LFlagsB = -O
endif
# Lahey F95 compiler
ifeq (${F90},lf95)
comp = -c -O -M ${Mdir} -I${InDir}
LFlagsB = -O
endif
# NAG f95/2003
ifeq (${F90},nagfor)
comp = -c -O -DONLYDOUBLE -mdir ${Mdir} -I${InDir}
LFlagsB = -O
endif
.SUFFIXES : .o .ps .f90 .F90 .a
bin/SPheno: ${name} SPheno4.o
${F90} -o SPheno ${LFlagsB} SPheno4.o ../lib/${name}
mv SPheno ../bin
${name}: ${name}(Control.o) ${name}(Mathematics.o) ${name}(RGEs.o) \
${name}(MathematicsQP.o) ${name}(LoopFunctions.o) ${name}(StandardModel.o) \
${name}(Model_Data.o) ${name}(Couplings.o) ${name}(SusyMasses.o) \
${name}(LoopCouplings.o) ${name}(DecayFunctions.o) \
${name}(SusyDecays.o) ${name}(ThreeBodyPhaseSpace.o) \
${name}(ThreeBodyPhaseSpaceS.o) ${name}(Chargino3.o) \
${name}(Gluino3.o) ${name}(Neutralino3.o) \
${name}(Stop3BodyDecays.o) ${name}(Slepton3Body.o) ${name}(BranchingRatios.o) \
${name}(EplusEminusProduction.o) ${name}(TwoLoopHiggsMass.o) \
${name}(LoopMasses.o) ${name}(SugraRuns.o) ${name}(Experiment.o) \
${name}(LowEnergy.o) ${name}(NMSSM_tools.o) ${name}(RPtools.o) \
${name}(LHC_observables.o) ${name}(InputOutput.o)
clean:
rm -f *.o *~ */*.o */*~
cleanall:
rm -f bin/SPheno4 lib/*.a *~ */*.o */*~ include/*
#
# Suffix rules
#
.f90.a:
${F90} ${comp} $<
ar -ruc $# $*.o
rm -f $*.o
.F90.a:
${F90} ${comp} ${PreDef} $<
ar -ruc $# $*.o
rm -f $*.o
.f90.o:
${F90} ${comp} $<
.f90.ps:
a2ps -o $*.ps $<
.h.ps:
a2ps -o $*.ps $<
I have a makefile, that I edited so that object files should go to a separate directory.
I edited the makefile and it is now doing what I wanted to, but during linker stage it is not working as expected because I am doing something wrong.
I have a sources file and makefile as shown below:
Sources File
TARGET = demo
SRC_DIR = modbus/ascii/ \
modbus/functions/ \
modbus/port/ \
modbus/rtu/ \
modbus/ \
./
INCLUDE_DIR = modbus/include/ \
modbus/port/ \
modbus/rtu \
modbus/ascii \
./
SOURCE = modbus/ascii/mbascii.c \
modbus/functions/mbfunccoils.c \
modbus/functions/mbfuncdiag.c \
modbus/functions/mbfuncdisc.c \
modbus/functions/mbfuncholding.c \
modbus/functions/mbfuncinput.c \
modbus/functions/mbfuncother.c \
modbus/functions/mbutils.c \
modbus/port/port.c \
modbus/port/portevent.c \
modbus/port/portserial.c \
modbus/port/porttimer.c \
modbus/rtu/mbcrc.c \
modbus/rtu/mbrtu.c \
modbus/mb.c \
demo.c \
startup_LPC17xx.c \
system_LPC17xx.c
Makefile
include ./sources
ARCH = arm-none-eabi
BUILD_DIR := build/objs
# Tool definitions
CC = $(ARCH)-gcc
LD = $(ARCH)-gcc
AR = $(ARCH)-ar
AS = $(ARCH)-as
CP = $(ARCH)-objcopy
OD = $(ARCH)-objdump
SIZE = $(ARCH)-size
RM = rm
Q = # #./quiet "$#"
# Flags
CFLAGS = -W -Wall -O0 --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb
CFLAGS += -ffunction-sections -fdata-sections
ASFLAGS =
LDFLAGS = -nostartfiles -specs=nosys.specs
CPFLAGS =
ODFLAGS = -x --syms
PRFLAGS ?=
# Source files
LINKER_SCRIPT = LPC17xx.ld
OBJS = $(SOURCE:.c=.o)
BUILD_OBJS := $(patsubst %,$(BUILD_DIR)/%,$(SOURCE:.c=.o))
OBJ_DIR := $(dir $(BUILD_OBJS))
INC_PARAMS = $(foreach d, $(INCLUDE_DIR), -I$d)
print-% : ; #echo $* = $($*)
.PHONY: all size clean nuke
all: $(TARGET).bin $(TARGET).hex
isp: $(TARGET).bin
# #./quiet $< cp $^ $(MBED_VOLUME)/
size: $(TARGET).elf
#$(SIZE) $<
%.hex: %.elf
$Q $(CP) $(CPFLAGS) -O ihex $< $*.hex
%.bin: %.elf
$Q $(CP) $(CPFLAGS) -O binary $< $*.bin
$(TARGET).elf: $(OBJS)
#touch $(#:.elf=.map)
$Q $(LD) -Xlinker -Map $(#:.elf=.map) $(LDFLAGS) -T $(LINKER_SCRIPT) $(BUILD_DIR)/$^ -o $#
$Q $(OD) $(ODFLAGS) $# > $(#:.elf=.dump)
#$(SIZE) $#
$(OBJS): %.o: %.c
mkdir -p $(dir $(BUILD_OBJS))
$Q $(CC) $(CFLAGS) $(INC_PARAMS) -c $< -o $(BUILD_DIR)/$#
.PHONY: clean
clean: CRUFT=$(shell find . -name '*.o' -o -name '*.d')
clean: ; rm -f $(CRUFT); rm -f *.elf *.hex *.bin *.dump *.map; rm -rf $(BUILD_DIR)/*
nuke: clean
-rm -f *.hex *.bin *.dump *.map
The issue is in line:
$Q $(LD) -Xlinker -Map $(#:.elf=.map) $(LDFLAGS) -T $(LINKER_SCRIPT) $(BUILD_DIR)/$^ -o $#
For which the output is:
arm-none-eabi-gcc -Xlinker -Map demo.map -nostartfiles -specs=nosys.specs -T LPC17xx.ld build/objs/modbus/ascii/mbascii.o modbus/functions/mbfunccoils.o modbus/functions/mbfuncdiag.o modbus/functions/mbfuncdisc.o modbus/functions/mbfuncholding.o modbus/functions/mbfuncinput.o modbus/functions/mbfuncother.o modbus/functions/mbutils.o modbus/port/port.o modbus/port/portevent.o modbus/port/portserial.o modbus/port/porttimer.o modbus/rtu/mbcrc.o modbus/rtu/mbrtu.o modbus/mb.o demo.o startup_LPC17xx.o system_LPC17xx.o -o demo.elf
The output command picks only the first object file from correct directory under build/objs.
Rest object file path doesn't have build/objs/.
Please anyone help me resolve this issue?
You are violating Mad Scientist's second rule of makefiles, and inviting more problems than you know.
Look at these rules (simplified):
$(TARGET).elf: $(OBJS)
$(LD) $(BUILD_DIR)/$^ -o $#
$(OBJS): %.o: %.c
$(CC) -c $< -o $(BUILD_DIR)/$#
Suppose the build directory is build/ and the object file is build/foo.o. The target of the second rule is foo.o, but what it actually builds is build/foo.o. Likewise, the first rule claims foo.o as a prerequisite, but it doesn't actually use foo.o, it uses build/foo.o These two errors cancel each other out, in a sense; Make succeeds in building the main target. But as you have found, it has trouble if there is more than one object file, because if the prerequisite list is foo.o bar.o, then
`$(BUILD_DIR)/$^`
expands to
build/foo.o bar.o
Also, Make will run the second rule even if build/foo.o exists and is up to date, and will fail to run it if foo.o exists. The target of a non-PHONY rule should be the name of the file it builds, and a non-PHONY prerequisite should be the name of a file whose existence is relevant:
$(TARGET).elf: $(BUILD_OBJS)
$(LD) $^ -o $#
$(BUILD_OBJS): $(BUILD_DIR)/%.o: %.c
$(CC) -c $< -o $#
I have the following makefile. When I run "make" or "make all", I get the following output:
make all -n
protoc -I protos/ --cpp_out=protos-gen/ protos//fd.proto
g++-4.9 -O4 -std=c++14 -g -I/usr/local/include -pthread -c -o protos-gen//fd.pb.o protos-gen//fd.pb.cc
protoc -I protos/ --grpc_out=protos-gen/ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` protos//fd.proto
python -m grpc_tools.protoc -I protos/ --python_out=protos-gen/ --grpc_python_out=protos-gen/ protos//fd.proto
g++-4.9 -O4 -std=c++14 -g -I/usr/local/include -pthread -c -o protos-gen//fd.grpc.pb.o protos-gen//fd.grpc.pb.cc
Issue is: I don't see the following line executed:
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_server_grpc.cpp $(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1 $(LIB) -lzmq -o $(BIN_DIR)/fd_server_grpc
What am I missing?
======================
SOURCE_DIR = src
BUILD_DIR = build
BIN_DIR = bin
DLIB_DIR = ../../3rdparty/dlib/
all: $(BIN_DIR)/fd_server_grpc $(BIN_DIR)/fd_client_grpc
$(BIN_DIR)/fd_server_grpc: $(PROTOS_GEN_PATH)/fd.pb.o
$(PROTOS_GEN_PATH)/fd.grpc.pb.o $(SOURCE_DIR)/fd_server_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_server_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1 $(LIB) -lzmq -o $(BIN_DIR)/fd_server_grpc
$(BIN_DIR)/fd_client_grpc: $(PROTOS_GEN_PATH)/fd.pb.o
$(PROTOS_GEN_PATH)/fd.grpc.pb.o $(SOURCE_DIR)/fd_client_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(SOURCE_DIR)/fd_client_grpc.cpp
$(DLIB_DIR)/dlib/all/source.cpp -DDLIB_JPEG_SUPPORT=1 -DDLIB_PNG_SUPPORT=1
$(LIB) -lzmq -o $(BIN_DIR)/fd_client_grpc
.PRECIOUS $(PROTOS_GEN_PATH)/fd.grpc.pb.cc $(PROTOS_GEN_PATH)/fd.pb.cc:
$(PROTOS_GEN_PATH)/fd.pb.o:$(PROTOS_GEN_PATH)/fd.pb.cc
$(PROTOS_GEN_PATH)/fd.pb.cc: $(PROTOS_PATH)/fd.proto
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=$(PROTOS_GEN_PATH) $(PROTOS_PATH)/fd.proto
$(PROTOS_GEN_PATH)/fd.grpc.pb.o:$(PROTOS_GEN_PATH)/fd.grpc.pb.cc
$(PROTOS_GEN_PATH)/fd.grpc.pb.cc: $(PROTOS_PATH)/fd.proto
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=$(PROTOS_GEN_PATH) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $(PROTOS_PATH)/fd.proto
python -m grpc_tools.protoc -I $(PROTOS_PATH) --python_out=$(PROTOS_GEN_PATH) --grpc_python_out=$(PROTOS_GEN_PATH) $(PROTOS_PATH)/fd.proto
clean:
rm -f $(BUILD_DIR)/* $(BIN_DIR)/* $(PROTOS_GEN_PATH)/*
I figured this out. The line $(CXX) did not start with a tab; had 8 spaces instead. Once I introduced tabs, it worked just fine. Thanks all!
Hi using the below make file how can I create all the object files in to a directory obj.
May be this question is very simple but no idea how to do it ?
Makefile
# Makefile
#### variables
RM= rm -vf
CXX = g++
CXXFLAGS = -Wall -g
CPPFLAGS = -I/usr/include/opencv -I/usr/include/opencv2
LDLIBS = -pthread -lbluetooth -lopencv_core -lopencv_imgproc -lopencv_highgui \
-lopencv_ml -lopencv_video -lopencv_features2d \
-lopencv_calib3d -lopencv_objdetect -lopencv_contrib \
-lopencv_legacy -lv4l1 -lv4l2 -lv4lconvert
SOURCEFILES = main.cpp \
bluetooth.cpp \
gpio.cpp \
wifi.cpp \
capturAndSend.cpp \
OBJECTFILES = $(patsubst %.cpp,%.o,$(SOURCEFILES))
PROGNAME= server
### rules
.PHONY: all clean
all: $(PROGNAME)
$(PROGNAME): $(OBJECTFILES)
$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $#
clean:
$(RM) $(OBJECTFILES) $(PROGNAME)
There are lots and lots of answers to this question available already. Did you look?
Try:
OBJECTFILES = $(patsubst %.cpp,obj/%.o,$(SOURCEFILES))
...
obj/%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $# $<
all: prd.exe
CC=cl
CFLAGS=-O2 -I../src -I. /W4
LDFLAGS = /Zi
LIBSRC = $(addprefix ../lib/, \
open.c malloc.c \
) \
$(addprefix ../src/, \
main.c \
) \
helper.c
LIBOBJS = $(LIBSRC:.c=.o)
prd.exe: ../src/main.obj
$(CC) $(LDFLAGS) -Fe$# *.o
../src/main.obj: ../src/main.c
$(CC) $(CFLAGS) $(LIBOBJS) -c $< -Fo $#
.c.o:
$(CC) $(CFLAGS) $(LIBOBJS) -c $< -Fo $#
.c.i:
$(CC) $(CFLAGS) $(LIBOBJS) -C -E $< > $#
clean:
del /s /f /q ..\lib\*.o ..\src\*.o *.o *.exe *.pdb
distclean: clean
I get this error
fatal error U1000: syntax error : ')' missing in macro invocation at line 6
Am i missing something here? nmake does recognize addprefix, right?
No, addprefix is a GNU make extension. You have a GNUmakefile that requires GNU make (gmake) to process.
Alternatively, you could rewrite the GNU makefile to not use GNU extensions. In your case this should be easy:
LIBSRC = $(addprefix ../lib/, \
open.c malloc.c \
) \
$(addprefix ../src/, \
main.c \
) \
helper.c
becomes
LIBSRC = ../lib/open.c ../lib/malloc.c ../src/main.c helper.c