Makefile No such file or directory

Makefile No such file or directory

Content Index :

Makefile No such file or directory
Tag : c , By : Paul McKee
Date : January 11 2021, 03:32 PM

this one helps. I'm trying to do some simple linked list practices to familiarize myself with C. I currently have the following makefile. , You need to compile the .c file, not .h; and get rid of -o app.
linked_list.o: linked_list.c linked_list.h
    $(CC) $(CFLAGS) -c linked_list.c
node.o: node.c node.h
    $(CC) $(CFLAGS) -c node.c

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Makefile with Dynamic Output Directory Based on Source File Directory

Tag : makefile , By : user180941
Date : March 29 2020, 07:55 AM
like below fixes the issue I'm trying to create a Makefile using a monorepo and am struggling a bit with dynamic output directories based on the source files' directories. , Something like this should do the job:
# Directories
PKGS_ROOT := packages

# Expands to the source directory for the specified package
pkg-srcdir = $(PKGS_ROOT)/$1/$(PKGS_SRCDIR)
# Expands to the output directory for the specified package
pkg-libdir = $(PKGS_ROOT)/$1/$(PKGS_OUTDIR)
# Expands to all output targets for the specified package
pkg-libs = $(addprefix $(call pkg-libdir,$1)/,$(notdir $(wildcard $(call pkg-srcdir,$1)/*.js)))

# Defines the following rules for the specified package:
#  - build rule for .js files
#  - rule to create the output directory if missing
#  - package rule to build all outputs
#  - clean-package rule to remove the output directory
# Adds the following prerequisites:
#  - package target to 'all' rule
#  - clean-package target to 'clean' rule
define pkg-rules
$(call pkg-libdir,$1)/%.js: $(call pkg-srcdir,$1)/%.js | $(call pkg-libdir,$1)
    @echo Making $$@ from $$^
    @cp $$^ $$@
$(call pkg-libdir,$1):
    @mkdir $$@
$1: $(call pkg-libs,$1)
    rm -rf $(call pkg-libdir,$1)
all: $1
clean: clean-$1
.PHONY: $1 clean-$1

# Creates rules for the specified package
add-pkg = $(eval $(call pkg-rules,$1))

# Create rules for all packages
PKGS := $(notdir $(wildcard $(PKGS_ROOT)/*))
$(foreach p,$(PKGS),$(call add-pkg,$p))

# Will be filled in by pkg-rules
.PHONY: all clean


makefile fatal error: no such file or directory, but the file is in current directory

Tag : c , By : MikeG
Date : March 29 2020, 07:55 AM
help you fix your problem Your makefile looks fine. The basic structure of a makefile contains this pattern:
<build object> : <list of dependencies>
       command to execute to build the object if dependencies have changed
       command to execute to build the object if dependencies have changed
#include <lib.c>
#include "lib.h"

Makefile from one source Directory trying to access a cpp file from other Directory

Tag : cpp , By : beebob
Date : March 29 2020, 07:55 AM
around this issue Adding vpath %.cpp ../hello along with @gaoithe's solution has solved this issue.
vpath %.cpp ../hello
OBJ=$(addprefix $(OBJDIR)/, $(patsubst %.cpp, %.o, $(wildcard *.cpp)))
OBJ+=$(addprefix $(OBJDIR)/, $(patsubst %.cpp, %.o, $(notdir $(wildcard ../hello/*.cpp))))

.PHONY: all clean

all: $(OBJDIR) $(TARGET)

    mkdir $(OBJDIR)

$(OBJDIR)/%.o: %.cpp
    $(GCC) $(CPPFLAGS) -c $< -o $@
    $(GCC) $(LDFLAGS) -o $@ $^
    @rm -f $(TARGET) $(wildcard *.o)
    @rm -rf $(OBJDIR)
$ ls objdir/
 Hello.o  main.o   World.o  

Update file (overwrite) file if file in other directory has changed. Simple Makefile

Tag : makefile , By : usingtechnology
Date : March 29 2020, 07:55 AM
hope this fix your issue I have a file dir/a.txt which is updated occasionally. When I run make I need to update a file in the current directory a.txt such that it is overwritten with dir/a.txt if the latter has changed. I tried this , You do it like this:
.PHONY: all

all: a.txt

a.txt: dir/a.txt
    cp $< $@
cp dir/a.txt a.txt
.PHONY: all

Why is the makefile returning g++: error: h file or directory make: *** [Makefile:12: test] Error 1?

Tag : cpp , By : user157654
Date : March 29 2020, 07:55 AM
To fix this issue The problem is that $^ and $@ is not working as you expected. $@ and $^ return the left and right values of $OBJ. However $OBJ simply resolves to "test.o".
OBJ = $(SRC:.cpp=.o) # converts test.cpp to test.o
CXX = g++
CXXFLAGS = -c -Wall -Wextra -Werror
LDFLAGS =  -lgmp -lsodium -lssl -lcrypto -lgmpxx
SRC = $(wildcard *.cpp )
HDR = $(wildcard *.h )
OBJ = $(SRC) $(SRC :.cpp =.o )
all : Release
Debug : CXXFLAGS +=-g
Debug : test
Release : test
test : $(OBJ)
    $(CXX) -o $@ $^ $(LDFLAGS)
%.o : %.cpp $(HDR)
    $(CXX) $(CXXFLAGS) $< -o $@
clean :
    rm -f $(OBJ) test
Related Posts Related QUESTIONS :
  • Why am I not getting error when I store values of different types in an array in C language?
  • What is the purpose of the base case dp[0] = -1 of this DP array in the palindromic partitions problem?
  • Having function choose largest number of given ones
  • Data structures layout
  • How to retrieve probuf from C library
  • Printf float number in hexadecimal format returns random vlaue
  • Memory allocation in C from 1 to N
  • Emit signal from separate thread in glib/gtk
  • How to fix Valgrind "Conditional Jump..." error
  • The text to be printed is being printed on the command line rather than print space while using fork on terminal
  • Deleting an element from an array of structures
  • How to read time stamp data from text file using C code?
  • I can't understand this code? Is it normal or I'm not ready?
  • GTK character count vs byte index
  • Summing up integers in an array and storing the result in an array
  • JITtting with limited knowledge of the target architecture
  • Why does global pointers behave erratically in this function?
  • Write a basic half pyramid pattern program
  • Read memory in C
  • void affecting output of the program
  • How to limit scanf while reading input from file
  • Why does the C runtime not call my exit()?
  • Can anyone say why the array is not changed when passed to a function
  • Integer overflow (Smallest file size that will make the integer in program become negative in bits)
  • Array of pointers to strings(base type of pointers)
  • Is there any way to limit integer datatype value range
  • How to print 2-byte unicode characters
  • The execution of open when using O_CREAT
  • Parsing Command Line Arguments for Shell
  • Undefined length of character arrays
  • Do condition formats in if/else if statements have to match in C?
  • Generate ordered passwords for brute forcing in C
  • Problems with pointer into structure
  • Why does this C program print output "10" irrespective of the for loop?
  • taking output 2D array in matrix form
  • sizeof char pointer and pointer to pointer
  • does the following program cause memory leak?
  • Innacurate file readings from fopen and/or fscanf
  • Searching an element in an Array using Recursive Function in C Language
  • Most fastest C code to count recursively directories in Linux ( without files )
  • Why does C not offer syntactically transparent references like C++ and Java do?
  • Code doesn't get excuted after using continue in while loop
  • How can I maintain correlation between structure definitions and their construction / destruction code?
  • Avoid race conditions when using pointers and threads
  • Binary and Decimal converting
  • How to create input tensors and use with interpreter in Tensorflow Lite (experimental C API)?
  • Unexpected typecasting between values in C
  • Trouble with Forking Process and Calling bc using execve
  • Glib Threads vs GMain Loop Eventing
  • Why does the byte sequence turn when I cast a char array to an integer array?
  • Is there any difference usage in external interrupt between GPIO (AHB bus)and those (APB bus)?
  • Trouble programming AVR to interpret input from Arduino rotary encoder module
  • Is it correct to use a do-while loop inside a for loop? Why and why not?
  • Why we can't use dot for new created pointers to structs
  • Atomicity of fprintf from MPI processes
  • Printing of negative value in c via printf
  • What's the difference between global or local variables regarding the main function?
  • movsd from memory to xmm0 in c x86-64 jit
  • Problem with a function that insert the content of a csv into an array of struct
  • Segmentation Fault running time on sem_post(flag)
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com