Hi, I'm Zixuan Wang, a PhD candidate at UCSD, doing research on memory systems.
I maintain a few open-source projects, see below for more details.
I take photos, check my photo blog.
More info on my website.
Makefile templates for different sized projects
License: MIT License
Hi, I'm Zixuan Wang, a PhD candidate at UCSD, doing research on memory systems.
I maintain a few open-source projects, see below for more details.
I take photos, check my photo blog.
More info on my website.
https://www.gnu.org/software/make/manual/make.html#Implicit-Variables provides common variable names which should be followed out of convention.
In particular, the example at
Makefile-Templates/SmallProject/Example/Makefile
Lines 2 to 3 in 884540b
CC := gcc
or CXX := g++
, and the common flags variable name is CFLAGS
or CXXFLAGS
, depending on if it's C or C++.I was using this Small Template to play with a dummy project I created to learn a bit about git.
However, after making some branches, some changes and committing and pushing them up to my github repository, I tried to recompile the project but it failed due to some multiple definition of a function. I had to 'make clean' and 'make' again to be able to compile the project with updated object files.
It should rather detect that the obj files were outdated and relink them all again.
It's possiable to add configure to makefile?
-s
option in MAKEFLAGS
causes compilation failure.
Building Project
make[1]: *** No rule to make target 's'. Stop.
/home/ubuntu/Makefile-Templates/MediumProject/Example/config/make.global:18: recipe for target 'src1' failed
make: *** [src1] Error 2
-s
option.The MediumExample can be compiled successfully after removing the -s
option.
Hi.
In line 20, we are requested to enter the file that contains function 'main.c'. The docs says to place main.c in root directory (I assume not inside src/).
MAIN_SRC :=# FILL: src file contains
main()``
This macro is not being used when object files are created, so main.o is never created, making the compilation to fail.
Workaround is to place main.c inside src/ and add it to Makefile like so:
MAIN_SRC :=src/main.c
Some compilation error occurs when linking libxml2.
Moving CCFLAGS to the end solves the problem, but I'm not sure why.
CCFLAGS is set to
CCFLAGS := -I/usr/include/libxml2 -lxml2
Solution
diff --git a/Makefile b/Makefile
index 94d8e0505876947c8f6786343cd178b4ef846035..390ae65500b699557b3da12391e05e75ae94b2e7 100644
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ default: makedir all
# non-phony targets
$(TARGET): $(OBJ)
- $(CC) $(CCFLAGS) -o $@ $(OBJ)
+ $(CC) -o $@ $(OBJ) $(CCFLAGS)
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
$(CC) $(CCOBJFLAGS) -o $@ $<
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.