math.h refer failure when compile LinSched 3.3 under 64-bit Ubuntu12.04 - linux

Compiling the LinSched 3.3 under 64-bit Ubuntu-12.04 throws me the following errors:
******/home/xxxxx/Desktop/linsched_3.3/tools/linsched/tests/linsched_rand_test.c:169: undefined reference to `sqrt'
collect2: ld returned 1 exit status
make[1]: [linsched_rand_test] Error 1
make[1]: Leaving directory `/home/jianguo/Desktop/linsched_3.3/tools/linsched/tests'
make: [all] Error 2*
Seems there is a problem when refer/link to the math.h, which is:
math: /usr/include/math.h
From the make file of LinSched 3.3, the CFLAGS and LFLAGS are defined as follows,
CC = ${CROSS_COMPILE}gcc
CFLAGS = -g -O2 -m64 -D__KERNEL__ -D__LINSCHED__ -Wall -Wundef -Wstrict-prototypes \
-Werror-implicit-function-declaration -fno-common \
-I${LINSCHED_DIR}/include -I${LINUXDIR}/include \
-I${LINUXDIR}/arch/linsched/include -I${LINSCHED_DIR}/ \
-include ${LINSCHED_DIR}/include/generated/autoconf.h \
-Wno-pointer-sign -include ${LINUXDIR}/include/linux/kconfig.h
CFLAGS_LINUX = $(CFLAGS) -nostdinc -isystem $(shell $(CC) -print-file-name=include) \
-include ${LINSCHED_DIR}/linux_linsched.h \
-Wno-unused -Wno-strict-aliasing
LFLAGS = -lm
....
...
...
LD_PERCPU = ${LD} -r -T ${LINSCHED_DIR}/linsched.lds
OBJ_FILES = ${LINSCHED_OBJS} ${LINUX_OBJS}
DEPS := ${OBJ_FILES:.o=.d}
-include ${DEPS}
TIME_HDR=${LINUXDIR}/kernel/timeconst.h
${TIME_HDR}: ${LINUXDIR}/kernel/timeconst.pl
#echo "(Generating timeconst.h)"
#perl ${LINUXDIR}/kernel/timeconst.pl 1000 > $#
${LINUX_OBJS}: %.o: %.c ${TIME_HDR}
#echo "CC KERNEL $<"
#${CC} -o $# ${CFLAGS_LINUX} -c $< -MMD
%.o: %.c
#echo "CC SIM $<"
#${CC} ${CFLAGS} -o $# -c $< -MMD
Someone on the web suggested to add -lm into the CFLAGS, I tried to insert the -lm parameter to several places of the CFLAGS, but the same errors persist.
Any idea ???
BTW, I compiled the LinSched 3.3 under 64-bit ubuntu becasue in the CFLAGS it is configured as -m64. And a former compile under 32-bit Ubuntu throws me error of data incompatibility(between elf64-x86-64 and elf32-i386)
As suggested by #another.anon.coward, I checked how the LFLAGs is used later, and find it is vever used. As a solution, how should I modify the makefile to add the LFLAGS parameter ???

Actually the issue was that linker flag ${LFLAGS} was used in /tools/linsched/tests/Makefile incorrectly.
Here is the patch that fixes the math library link related build issue for linsched:
diff --git a/tools/linsched/tests/Makefile b/tools/linsched/tests/Makefile
index 91bb8eb..8074c93 100644
--- a/tools/linsched/tests/Makefile
+++ b/tools/linsched/tests/Makefile
## -33,7 +33,7 ## TEST_DEPS := ${TESTS:%=%.d}
${TESTS}: ${OBJ_FILES} $$#.o
#echo CC TEST $#
#${LD_PERCPU} -o $#.percpu $^
- #${CC} ${LFLAGS} -o $# $#.percpu -MMD
+ #${CC} -o $# $#.percpu ${LFLAGS} -MMD
#rm $#.percpu
clean:

Related

How to fix ld: cannot find kernel.bin: No such file or directory

I'm trying to run an implementation of an operating system and I get this error when I run make on the terminal, I use ubuntu 20.04.
This is the makefile:
C_SOURCES = $(wildcard kernel/*.c drivers/*.c cpu/*.c libc/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h libc/*.h)
# Nice syntax for file extension replacement
OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
# Change this if your cross-compiler is somewhere else
CC = /usr/local/i386elfgcc/bin/i386-elf-gcc
GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb
# -g: Use debugging symbols in gcc
CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions -m32
# First rule is run by default
os-image.bin: boot/bootsect.bin kernel.bin
cat $^ > os-image.bin
# '--oformat binary' deletes all symbols as a collateral, so we don't need
# to 'strip' them manually on this case
kernel.bin: boot/kernel_entry.o ${OBJ}
ld -melf_i386 -o -no-PIE $# -Ttext 0x1000 $^ --oformat binary
# Used for debugging purposes
kernel.elf: boot/kernel_entry.o ${OBJ}
ld -melf_i386 -o -no-PIE $# -Ttext 0x1000 $^
run: os-image.bin
qemu-system-i386 -fda os-image.bin
# Open the connection to qemu and load our kernel-object file with symbols
debug: os-image.bin kernel.elf
qemu-system-i386 -s -fda os-image.bin -d guest_errors,int &
${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
# Generic rules for wildcards
# To make an object, always compile from its .c
%.o: %.c ${HEADERS}
${CC} ${CFLAGS} -c $< -o $#
%.o: %.asm
nasm $< -f elf -o $#
%.bin: %.asm
nasm $< -f bin -o $#
clean:
rm -rf *.bin *.dis *.o os-image.bin *.elf
rm -rf kernel/*.o boot/*.bin drivers/*.o boot/*.o cpu/*.o libc/*.o
And this is the source for the code, I wasn't able to install the cross compiler that is in the tutorial. So I tried to change the makefile to work with the default gcc:
source
You linker commands are buggy because you misplaced the -no-PIE option.
Instead of ld -o -no-PIE $#, write ld -o $# -no-PIE:
kernel.bin: boot/kernel_entry.o ${OBJ}
ld -melf_i386 -o $# -no-PIE -Ttext 0x1000 $^ --oformat binary
kernel.elf: boot/kernel_entry.o ${OBJ}
ld -melf_i386 -o $# -no-PIE -Ttext 0x1000 $^
$# is the target of your make command (here kernel.bin and kernel.elf). Misplacing it like you did, you are instructing ld to output the result as a file named -no-PIE and to use kernel.bin (resp. kernel.elf) as an input. Hence the error message since the input does not exist yet.

Passing CFLAGS to Makefile at a command line

I am trying to monitor coverage on a Makefile project.
CFLAGS=" -fprofile-arcs -ftest-coverage -g" make test
But the command above does not seem to work, producing the following:
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o test.c
mv -f .deps/test.Tpo .deps/test.Po
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I.. -g -O2 -MT gaussian.lo -MD -MP -MF .deps/gaussian.Tpo -c -o gaussian.lo gaussian.c
It can be seen, from the first line, that CFLAGS are not well added when gcc is invoked. How can I include the cflags in gcc's build options while launching "make"?
I am using Bash at an Ubuntu 14, if that matters.
Variables obtained from the environment, which is how you're doing it, have a lower precedence than variables set in a makefile. So if your makefile sets the CFLAGS variable directly, like:
CFLAGS = -g -O2
then setting it in the environment won't override this setting.
You can add variable assignments to the command line instead: these take precedence over almost anything set in the makefile. So use:
make test CFLAGS=" -fprofile-arcs -ftest-coverage -g"
instead.
See https://www.gnu.org/software/make/manual/html_node/Values.html

outside header file not found during compilation

I'm trying to compile the bpf samples, outside the tree.
Here's my folder:
.
├── bpf_load.c
├── bpf_load.h
├── bpf_load.o
├── libbpf.h
├── Makefile
├── xdp1
├── xdp1_kern.c
├── xdp1_kern.o
├── xdp1_user.c
├── xdp2_kern.c
└── xdp2_user.c
And this is the Makefile:
#
# Makefile for out-of-tree building eBPF programs
# similar to kernel/samples/bpf/
#
# Still depend on a kernel source tree.
#
TARGETS = xdp1
TOOLS_PATH = /usr/src/kernels/$(shell uname -r)/tools
TARGETS_ALL = $(TARGETS)
# Generate file name-scheme based on TARGETS
KERN_SOURCES = ${TARGETS_ALL:=_kern.c}
USER_SOURCES = ${TARGETS_ALL:=_user.c}
KERN_OBJECTS = ${KERN_SOURCES:.c=.o}
USER_OBJECTS = ${USER_SOURCES:.c=.o}
# Notice: the kbuilddir can be redefined on make cmdline
kbuilddir ?= /lib/modules/`uname -r`/build/
KERNEL=$(kbuilddir)
CFLAGS := -g -O2 -Wall
# Local copy of include/linux/bpf.h kept under ./kernel-usr-include
#
CFLAGS += /usr/include/linux/bpf.h
#
# Interacting with libbpf
CFLAGS += -I$(TOOLS_PATH)/lib
CFLAGS += -I$(TOOLS_PATH)/testing/selftests/bpf
LDFLAGS= -lelf
# Objects that xxx_user program is linked with:
OBJECT_LOADBPF = bpf_load.o
OBJECTS = $(OBJECT_LOADBPF)
#
# The static libbpf library
LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
# Allows pointing LLC/CLANG to another LLVM backend, redefine on cmdline:
# make LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
LLC ?= llc
CLANG ?= clang
CC = gcc
NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# TODO: can we remove(?) copy of uapi/linux/bpf.h stored here: ./tools/include/
# LINUXINCLUDE := -I./tools/include/
#
# bpf_helper.h need newer version of uapi/linux/bpf.h
# (as this git-repo use new devel kernel features)
KERNEL_PATH = /usr/src/kernels/$(shell uname -r)
LINUXINCLUDE := -I$(KERNEL_PATH)/include
#
LINUXINCLUDE += -I$(KERNEL_PATH)/arch/x86/include
LINUXINCLUDE += -I$(KERNEL_PATH)/arch/x86/include/generated/uapi
LINUXINCLUDE += -I$(KERNEL_PATH)/arch/x86/include/generated
LINUXINCLUDE += -I$(KERNEL_PATH)/include
LINUXINCLUDE += -I$(KERNEL_PATH)/arch/x86/include/uapi
LINUXINCLUDE += -I$(KERNEL_PATH)/include/uapi
LINUXINCLUDE += -I$(KERNEL_PATH)/include/generated/uapi
LINUXINCLUDE += -include $(KERNEL_PATH)/include/linux/kconfig.h
#LINUXINCLUDE += -I$(KERNEL)/tools/lib
EXTRA_CFLAGS=-Werror
all: dependencies $(TARGETS_ALL) $(KERN_OBJECTS)
.PHONY: dependencies clean verify_cmds verify_llvm_target_bpf $(CLANG) $(LLC)
# Most xxx_user program still depend on old bpf_load.c
$(OBJECT_LOADBPF): bpf_load.c bpf_load.h
$(CC) $(CFLAGS) -o $# -c $<
LIBBPF_SOURCES = $(TOOLS_PATH)/lib/bpf/*.c
# New ELF-loaded avail in libbpf (in bpf/libbpf.c)
$(LIBBPF): $(LIBBPF_SOURCES) $(TOOLS_PATH)/lib/bpf/Makefile
make -C $(TOOLS_PATH)/lib/bpf/ all
# Compiling of eBPF restricted-C code with LLVM
# clang option -S generated output file with suffix .ll
# which is the non-binary LLVM assembly language format
# (normally LLVM bitcode format .bc is generated)
#
# Use -Wno-address-of-packed-member as eBPF verifier enforces
# unaligned access checks where necessary
#
$(KERN_OBJECTS): %.o: %.c Makefile
$(CLANG) -S $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
-D__KERNEL__ -D__ASM_SYSREG_H \
-D__BPF_TRACING__ \
-Wall \
-Wno-unused-value -Wno-pointer-sign \
-D__TARGET_ARCH_$(ARCH) \
-Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-tautological-compare \
-Wno-unknown-warning-option \
-Wno-address-of-packed-member \
-O2 -emit-llvm -c $< -o ${#:.o=.ll}
$(LLC) -march=bpf -filetype=obj -o $# ${#:.o=.ll}
$(TARGETS): %: xdp1_user.c $(OBJECTS) $(LIBBPF) Makefile
$(CC) $(CFLAGS) $(OBJECTS) $(LDFLAGS) -o $# $< $(LIBBPF)
I pretty much just copied the makfile I found here:
https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/samples/bpf/Makefile
and deleted a bunch of stuff that I didn't need, and also changed it to be more dynamic and calculate the different paths using 'uname -r'.
The problem is that the original Makefile assumed that bfp_helpers.h is in the same directory as the files. But my xdp1_kern.c uses it and I can't have it in the same directory. I add -I(path to bpf_helpers.h) but it still throws error when I run it.
make LLC=<path to llc> CLANG=<path to clang>
gcc -g -O2 -Wall /usr/include/linux/bpf.h -I/usr/src/kernels/4.18.0-mlnx/tools/lib -I/usr/src/kernels/4.18.0-mlnx/tools/testing/selftests/bpf bpf_load.o -lelf -o xdp1 xdp1_user.c /usr/src/kernels/4.18.0-mlnx/tools/lib/bpf/libbpf.a
/.autodirect/net_linux_verification/tools/clang+llvm-3.8.0-linux-x86_64-centos6/bin/clang -S -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/usr/src/kernels/4.18.0-mlnx/include -I/usr/src/kernels/4.18.0-mlnx/arch/x86/include -I/usr/src/kernels/4.18.0-mlnx/arch/x86/include/generated/uapi -I/usr/src/kernels/4.18.0-mlnx/arch/x86/include/generated -I/usr/src/kernels/4.18.0-mlnx/include -I/usr/src/kernels/4.18.0-mlnx/arch/x86/include/uapi -I/usr/src/kernels/4.18.0-mlnx/include/uapi -I/usr/src/kernels/4.18.0-mlnx/include/generated/uapi -include /usr/src/kernels/4.18.0-mlnx/include/linux/kconfig.h -Werror \
-D__KERNEL__ -D__ASM_SYSREG_H \
-D__BPF_TRACING__ \
-Wall \
-Wno-unused-value -Wno-pointer-sign \
-D__TARGET_ARCH_ \
-Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-tautological-compare \
-Wno-unknown-warning-option \
-Wno-address-of-packed-member \
-O2 -emit-llvm -c xdp1_kern.c -o xdp1_kern.ll
xdp1_kern.c:15:10: fatal error: 'bpf_helpers.h' file not found
#include "bpf_helpers.h"
^
1 error generated.
make: *** [Makefile:93: xdp1_kern.o] Error 1
I'm was sure that adding -I/usr/src/kernels/4.18.0-mlnx/tools/testing/selftests/bpf will solve it as this is where bpf_helpers.h are on my machine. But it didn't, it only solved the include for bpf_utils.h.
You do not use the CFLAGS you modified when trying to compile your BPF program.
You do use the CFLAGS when compiling the user space programs:
# Most xxx_user program still depend on old bpf_load.c
$(OBJECT_LOADBPF): bpf_load.c bpf_load.h
$(CC) $(CFLAGS) -o $# -c $<
And
$(TARGETS): %: xdp1_user.c $(OBJECTS) $(LIBBPF) Makefile
$(CC) $(CFLAGS) $(OBJECTS) $(LDFLAGS) -o $# $< $(LIBBPF)
The latter gives you your first two lines of output, where your directory to search does appear:
make LLC=<path to llc> CLANG=<path to clang>
gcc -g -O2 -Wall [...] -I/usr/src/kernels/4.18.0-mlnx/tools/testing/selftests/bpf [...]
However, starting from the next line, this is a different command, calling clang to compile your BPF program. It comes from that Makefile code:
$(KERN_OBJECTS): %.o: %.c Makefile
$(CLANG) -S $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
[...]
... Which does not use the $(CFLAGS). Just add it to the clang command in the Makefile, this should solve your problem.

How does this Makefile work?

This is the makefile:
GOOGLE_APPLICATION_CREDENTIALS=/home/roman/Documents/Google_Cloud/SpeechRec.json
GOOGLEAPIS_GENS_PATH=/home/roman/Downloads/GoogleAPIs/googleapis/gens
GOOGLEAPIS_GENS_PATH ?= $(HOME)/gitrepos/googleapis/gens
GOOGLEAPIS_API_CCS = $(shell find $(GOOGLEAPIS_GENS_PATH)/google/api \
-name '*.pb.cc')
GOOGLEAPIS_RPC_CCS = $(shell find $(GOOGLEAPIS_GENS_PATH)/google/rpc \
-name '*.pb.cc')
GOOGLEAPIS_SPEECH_CCS = $(shell find \
$(GOOGLEAPIS_GENS_PATH)/google/cloud/speech -name '*.pb.cc')
GOOGLEAPIS_LONGRUNNING_CCS = $(shell find \
$(GOOGLEAPIS_GENS_PATH)/google/longrunning -name '*.pb.cc')
GOOGLEAPIS_CCS = $(GOOGLEAPIS_API_CCS) $(GOOGLEAPIS_RPC_CCS) \
$(GOOGLEAPIS_LONGRUNNING_CCS) $(GOOGLEAPIS_SPEECH_CCS)
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
SYSTEM ?= $(HOST_SYSTEM)
CXX = g++
CPPFLAGS += -I/usr/local/include -pthread -I$(GOOGLEAPIS_GENS_PATH) -g -O0
CXXFLAGS += -std=c++11 -g -O0
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` \
-lgrpc++_reflection \
-lprotobuf -lpthread -ldl
else
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` \
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed \
-lprotobuf -lpthread -ldl
endif
.PHONY: all
#all: transcribe async_transcribe streaming_transcribe streaming_transcribe_singlethread
all: streaming_transcribe
googleapis.ar: $(GOOGLEAPIS_CCS:.cc=.o)
ar r $# $?
streaming_transcribe: streaming_transcribe.o parse_arguments.o googleapis.ar
$(CXX) $^ $(LDFLAGS) -o $#
It produces log result:
23:20:19 **** Build of configuration Build (GNU) for project GoogleSpeechApi ****
make all
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o streaming_transcribe.o streaming_transcribe.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o parse_arguments.o parse_arguments.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/log.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/log.grpc.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.grpc.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.grpc.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.grpc.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.grpc.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.pb.cc
g++ -std=c++11 -g -O0 -I/usr/local/include -pthread -I/home/roman/Downloads/GoogleAPIs/googleapis/gens -g -O0 -c -o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/httpbody.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/httpbody.grpc.pb.cc
ar r googleapis.ar /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/log.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/authorization_config.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/experimental/experimental.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/servicemanager.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicemanagement/v1/resources.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/httpbody.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/label.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/billing.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/quota_controller.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/service_controller.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/log_entry.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/metric_value.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/operation.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/operation.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/check_error.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/quota_controller.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/log_entry.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/check_error.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/metric_value.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/distribution.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/distribution.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/servicecontrol/v1/service_controller.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/httpbody.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/consumer.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/billing.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/config_change.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/monitored_resource.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/http.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/backend.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/documentation.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/metric.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/system_parameter.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/consumer.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/control.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/documentation.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/monitored_resource.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/logging.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/http.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/backend.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/annotations.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/auth.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/usage.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/metric.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/service.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/usage.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/log.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/service.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/auth.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/source_info.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/endpoint.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/endpoint.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/quota.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/system_parameter.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/annotations.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/context.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/logging.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/distribution.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/config_change.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/source_info.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/distribution.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/monitoring.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/control.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/quota.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/monitoring.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/label.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/api/context.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/error_details.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/status.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/code.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/code.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/status.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/rpc/error_details.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/longrunning/operations.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/longrunning/operations.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1beta1/cloud_speech.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1beta1/cloud_speech.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1/cloud_speech.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1/cloud_speech.grpc.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1_1beta1/cloud_speech.pb.o /home/roman/Downloads/GoogleAPIs/googleapis/gens/google/cloud/speech/v1_1beta1/cloud_speech.grpc.pb.o
ar: creating googleapis.ar
g++ streaming_transcribe.o parse_arguments.o googleapis.ar -L/usr/local/lib `pkg-config --libs grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -lprotobuf -lpthread -ldl -o streaming_transcribe
23:23:26 Build Finished (took 3m:7s.68ms)
I can only understand first two lines in the log. How all this files:
/home/roman/Downloads/GoogleAPIs/googleapis/gens/google
files get to compiling? They are contained in
GOOGLEAPIS_CCS
variable and it is only used in makefile in
ar r $# $?
string. Can you explain step by step how this actually work?
The following rule makes a static library that depends on the object files that will result from compiling all of the discovered source files:
googleapis.ar: $(GOOGLEAPIS_CCS:.cc=.o)
ar r $# $?
The way this works is that $(GOOGLEAPIS_CCS:.cc=.o) means "take the variable GOOGLEAPIS_CCS, and within it, replace every occurance of .cc with .o". That is, convert the discovered lists of sources into a list of the object files that will be generated from them. Because this is on the prerequisite line, make will try to find a rule for how to produce these objects.
There are no explicit rules in the Makefile for building the .o files, so make will use one of the built-in implicitly defined pattern rules. Specifically:
%.o: %.cc
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $# $^
So that causes all of the compilation you see in your output. Once these are built, the rule we were looking at above archives them into a static library. That static library is one of the prerequisites for the main build target, which is what triggers all of the above to be evaluated.
It may be obvious, but for completeness, all of the initial variable declartions use $(shell find ...). This literally runs the find command via the shell to recursively traverse the specified directory, and list the files that match the given pattern (e.g., *.cc). The result is that these variables are defined as the list of matching filenames.

No rule to make target f1.o, needed by f90_simple

I have the following makefile. It works well for .f and .c files but when I have .f90 file and want to compile it with ifort does not work?
Could you please advise me where I should change and how?
Thanks you
FCOMPFLAGS = -O -ffixed-line-length-132
CCOMPFLAGS = -O
FFLAGS = $(FCOMPFLAGS) -fsecond-underscore
CFLAGS = $(CCOMPFLAGS)
LDFLAGS = $(FCOMPFLAGS)
LD = gfortran
FC = gfortran
MAKEFILE = Makefile
PROGRAM1 = f1
OBJS = f1.o \
f2.o \
f3.o
all: $(PROGRAM1)
$(PROGRAM1): $(OBJS) $(MAKEFILE)
$(LD) $(LDFLAGS) $(OBJS) -o $(PROGRAM1)
clean: #rm -f $(OBJS) core
when I execute "make" I get the following error,
make: *** No rule to make target `f1.o', needed by `f90_simple'. Stop.
It seems that My makefile does not recognize *.f90 files, and my other question is do we have flag for ifrot compiler to be used in makefile
Thanks
You need to add the implicit rule:
%.o : %.f90
<tab>$(FC) $(FCOMPLAGS) -c $<

Resources