cs50 / libcs50

This is CS50's Library for C.
https://cs50.readthedocs.io/libraries/cs50/c/
GNU General Public License v3.0
1.66k stars 831 forks source link

How does the make command automatically link to the cs50 library or the libraries used? #287

Closed CongMNguyen closed 1 year ago

CongMNguyen commented 1 year ago

I've been struggling with it all day and just found a way to create a makefile. But folders that do not contain makefile files will not automatically link to the cs50 library.

dmalan commented 1 year ago

See https://cs50.readthedocs.io/libraries/cs50/c/#makefile!

CongMNguyen commented 1 year ago

Thank you professor

goyalyashpal commented 1 month ago

just saving for myself:

MAKEFLAGS += --debug=why
# MAKEFLAGS += --no-silent
# MAKEFLAGS += --warn-undefined-variables

CC := clang
CFLAGS := -std=c11

# Below are common C[XX]FLAGS
CCFLAGS += -ferror-limit=1 -gdwarf-4 -ggdb3 -O0
CCFLAGS += -Wall -Werror -Wextra
CCFLAGS += -Wno-gnu-folding-constant -Wno-sign-compare
CCFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable
CCFLAGS += -Wshadow

CFLAGS += $(CCFLAGS)

# LDLIBS := -lcrypt -lcs50 -lm
LDLIBS := -lm

# Following is for use with IDEs like Geany, Kate, Eclipse, IntelliJ, PyCharm, etc
.PHONY: all

all: # <pset_file_basename_i.e._without_extension>

# EXE = foo

# SRCS = foo.c bar.c
# OBJS = $(SRCS:.c=.o)

# $(EXE): $(OBJS)
#   $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS)

# https://cs50.readthedocs.io/libraries/cs50/c/#makefile
# https://github.com/cs50/libcs50/issues/287

for using on windows, as these vars are essentially common to all the cs50x psets based on c-lang so, just cmd /c mklink /h Makefile <pset>\Makefile (ref: howtogeek/win-symlink)


References: