Make error: commands commence before first target - gcc

Makefile:
CC = gcc
CFLAGS = -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XSLT=1 -DXMLSEC_NO_XKMS=1 -I/usr/include/libxml2 -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO=\"openssl\" -DUNIX_SOCKETS -DXML_SECURITY -DDEBUG
LDFLAGS= -lcrypto -I/usr/include/libxml2 -lxml2 -I/usr/local/include/xmlsec1 -lxmlsec1
$(CC) $(CFLAGS) $(LDFLAGS) src/aadhaar.c src/uid_auth.c -o AuthClient
I'm getting this error: error: commands commence before first target

You seem to miss the target definition:
AuthClient : src/aadhaar.c src/uid_auth.c
$(CC) $(CFLAGS) $(LDFLAGS) src/aadhaar.c src/uid_auth.c -o $#

Related

modifying Makefile for silverfrost FTN95 ( Windows)

Compiling error
I am quite new to Fortran coding.
Currently, I have a makefile which has been previously used by original authors to compile the Fortran codes in Linux. However, I cannot understand what needs to be changed in the previous makefile to run it in Windows-based compiler Silverfrost FTN95.
While trying to compile in FTN95 I encountered the following error:
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>MAKE TPX
mpif90 -w -O3 -w -O3 -c ssizgrd.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c ssizgrd.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `ssizgrd.o' failed
MAKE: *** [ssizgrd.o] Error 2
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>make trg
mpif90 -w -O3 -w -O3 -c grids.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c grids.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `grids.o' failed
make: *** [grids.o] Error 2
Below is the Makefile code:
TRG = trg
PRG = prg
TPX = tpx
OBJT90 = trigrs.o flux.o prpijz.o svxmdv.o svijz.o dzero_brac.o
OBJT95 = grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o satfin.o savage.o steady.o trini.o unsinf.o ivestp.o pstpf.o rnoff.o satinf.o smallt.o svgstp.o unsfin.o unsth.o ssizgrd.o svlist.o
OBJT77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o isvgrd.o roots.o srdgrd.o srdswm.o ssvgrd.o
OBJP90 = trigrs_p.o partial_p.o flux.o flux_p.o prpijz.o svxmdv.o svijz.o dzero_brac.o srdgrd_p.o irdgrd_p.o
OBJP95 = modules_p.o grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o pstpi_p.o satfin.o satfin_p.o savage.o steady.o trini.o trini_p.o unsinf.o unsinf_p.o ivestp.o ivestp_p.o pstpf.o pstpf_p.o rnoff.o satinf.o satinf_p.o smallt.o svgstp.o svgstp_p.o unsfin.o unsfin_p.o unsth.o unsth_p.o ssizgrd.o ssizgrd_p.o svlist.o rnoff_p.o steady_p.o
OBJP77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o irdswm_p.o isvgrd.o roots.o srdgrd.o srdswm.o srdswm_p.o ssvgrd.o
OBJX90 = tpindx.o nxtcel.o
OBJX95 = ssizgrd.o
OBJX77 = isvgrd.o mpfldr.o rdflodir.o sindex.o slofac.o srdgrd1.o
LIBS =
CC = gcc -O3
CCFLAGS = -lgsl -lgslcblas -lm
FC = ftn95 -w -O3
FFLAGS =
F90 = f95 -w -O3
MPIF90 = mpif90 -w -O3
F90FLAGS = -w -O3
LDFLAGS = -w -O3
all: $(TRG) $(PRG)
#-----------------------------------------------------------------
$(TRG): $(OBJT95) $(OBJT90) $(OBJT77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJT95) $(OBJT90) $(OBJT77) $(CCFLAGS) $(LIBS)
$(PRG): $(OBJP95) $(OBJP90) $(OBJP77)
$(MPIF90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJP95) $(OBJP90) $(OBJP77)
$(CCFLAGS) $(LIBS)
$(TPX): $(OBJX95) $(OBJX90) $(OBJX77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJX95) $(OBJX90) $(OBJX77) $(CCFLAGS) $(LIBS)
#-----------------------------------------------------------------
clean:
rm -f $(TRG) $(TPX) $(PRG)
rm -rf $(OBJT95) $(OBJT90) $(OBJT77) $(OBJP95) $(OBJP90) $(OBJP77)
rm -rf $(OBJX95) $(OBJX90) $(OBJX77)
rm -rf *.mod *.exe *.stackdump
.SUFFIXES: $(SUFFIXES) .f90 .f .c .f95
.f90.o:
$(MPIF90) $(F90FLAGS) -c $<
.f.o:
$(MPIF90) $(F90FLAGS) -c $<
.c.o:
$(CC) $(CCINCLUDE) -c -w $<
.f95.o:
$(MPIF90) $(F90FLAGS) -c $<
What changes need to be made for the code to compile?

make error : *** missing separator. Stop

This is my makefile:
OBJECTS = main.o
CFLAGS = -g -wall
NAME = make
CC = gcc
build: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $(NAME)
I'm getting below error when I tried to make(Applied tab before gcc command) :
makefile:6: *** missing separator. Stop.
How can I fix this?
First of all, it looks like you have spaces instead of tab.
As for the Makefile itself, I'd make it little bit simpler. For a source file main.c:
int main() {
return 0;
}
I would go with Makefile:
CFLAGS = -g -wall
CC = gcc
main: main.c
$(CC) $(CFLAGS) $< -o $#

Make file macro

# this is a comment
OBJS = student.o teacher.o class.o
CC = g++
DEBUG = -g
CFLAGS = -Wall –c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
myproj.exe : $(OBJS)
$(CC) $(LFLAGS) $(OBJS) –o myproj.exe
student.o : student.h student.cpp
$(CC) $(CFLAGS) student.cpp
teacher.o : teacher.h teacher.cpp
$(CC) $(CFLAGS) teacher.cpp
class.o : class.h student.h teacher.h class.cpp
$(CC) $(CFLAGS) class.cpp
can someonte tell me why does CFLAGS and LFALGS have the $(DEBUG) behind?
So you don't have to write it every time you compile or link.
Lets take these two lines from your file:
student.o : student.h student.cpp
$(CC) $(CFLAGS) student.cpp
If you didn't have $(DEBUG) in $(CFLAGS) you would have to write
student.o : student.h student.cpp
$(CC) $(CFLAGS) $(DEBUG) student.cpp
And do it for every rule and command where you want to use $(DEBUG).

Makefile: object file not found

I have the following Makefile. Whenever I run make, I get the following error.
ifort: error #10236: File not found: 'mkl_matrix_multiply.o'
I have been trying to figure this out for a while now with no luck.
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe
Any help would be greatly appreciated.
Seems like you are missing -c in mkl_matrix_multiply.o rule.
Modify your makefile as
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) -c $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe

gcc makefile error: “No rule to make target …”

i'm trying to use GCC (linux) with a makefile to compile my project.
I get the following error :
% make map
make: *** No rule to make target `map'. Stop.
Does any one have any idea what could that be ?
This is the makefile:
CC = gcc
DEBUG_FLAG = -g
COMP_FLAG = -std=c99 -Wall -Werror -pedantic-errors -DNDEBUG
LIB = -L. -lmtm
MAP_OBJS = map.o
USER_OBJS = user.o
NETWORK_OBJS = network.o
ISOCIAL_OBJS = network.o user.o Isocial.o
PARSING_OBJS = user.o network.o map.o Isocial.o mtm_isocial.o
PARSING = parsing
MAP_TEST = map_example_test
ISOCIAL_TEST = Isocial_test
NETWORK_TEST = network_test
USER_TEST = user_test
TEST_PATH = ./tests/
$(PARSING) : $(PARSING_OBJS)
$(CC) $(DEBUG_FLAG) $(PARSING_OBJS) $(LIB) -o $#
$(MAP_TEST) : $(MAP_OBJS)
$(CC) $(DEBUG_FLAG) $(MAP_OBJS) $(LIB) -o $#
$(ISOCIAL_TEST) : $(ISOCIAL_OBJS)
$(CC) $(DEBUG_FLAG) $(ISOCIAL_OBJS) $(LIB) -o $#
$(USER_TEST) : &(USER_OBJS)
$(CC) $(DEBUG_FLAG) $(USER_OBJS) $(LIB) -o $#
$(NETWORK_TEST) : $(NETWORK_OBJS)
$(CC) $(DEBUG_FLAG) $(MAP_OBJS) $(LIB) -o $#
map.o: map.c map.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
isocial.o: Isocial.c user.h mtm_ex2.h set.h network.h list.h Isocial.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
parsing.o: parsing.c Isocial.h parsing.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
network.o: network.c network.h set.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
user.o:user.c user.h set.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
user_test.o: user_test.c ../test_utilities.h ../user.h ../mtm_ex2.h \
../set.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $(TEST_PATH)$*.c
Isocial_test.o: Isocial_test.c ../test_utilities.h ../Isocial.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
map_example_test.o: map_example_test.c ../test_utilities.h ../map.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
network_test.o: network_test.c ../test_utilities.h ../network.h ../set.h \
../mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
EXEC = $(PARSING) $(MAP_TEST) $(ISOCIAL_TEST $(USER_TEST) $(NETWORK_TEST)
tests : $(MAP_TEST) $(ISOCIAL_TEST) $(USER_TEST) $(NETWORK_TEST)
isocial : $(PARSING)
clean:
rm -f $(PARSING_OBJS) $(EXEC)
The error message is correct: I see a target for map.o, but there's no target for map, which would look like
map: map.o
something something something
There are targets for programs named parsing, map_example_test, network_test, and Isocial_test; perhaps you want to build one of those?
If you just typed make, it would build the program parsing, as that's the first target in the file.

Resources