I try to include static library gmp.h but Linux can not see it.
Terminal output like this:
gcc -Wall -Werror -Wextra -std=c11 -D OS_LINUX -I/../materials/LINUX_gmp_lib/include/ -L/../materials/LINUX_gmp_lib/lib -lgmp -c s21_*.c ar rc s21_decimal.a s21_*.o ranlib s21_decimal.a gcc -Wall -Werror -Wextra -std=c11 -D OS_LINUX -lgmp tests.c s21_decimal.a -lpthread -lcheck -pthread -lm -lrt -o test /usr/bin/ld: невозможно найти -lgmp: Нет такого файла или каталога collect2: error: ld returned 1 exit status make: *** [Makefile:31: test] Ошибка 1
my makefile look like this:
#.SILENT:
CC = gcc -Wall -Werror -Wextra -std=c11
GCOVFLAGS = -fprofile-arcs -ftest-coverage
LIBS = -lcheck
PROJECTNAME = s21_decimal
OS := $(shell uname -s)
ifeq ($(OS), Darwin)
CC += -D OS_MAC
GMP_PATH = -I/../materials/MAC_gmp_lib/include/ -L/../materials/MAC_gmp_lib/lib
TEST_FLAGS = $(LIBS)
GMP_FLAGS = -lgmp -Wl,-no_pie
endif
ifeq ($(OS), Linux)
CC += -D OS_LINUX
GMP_PATH = -I/../materials/LINUX_gmp_lib/include/ -L/../materials/LINUX_gmp_lib/lib
TEST_FLAGS = -lpthread $(LIBS) -pthread -lm -lrt
GMP_FLAGS = -lgmp
endif
all: $(PROJECTNAME).a
$(PROJECTNAME).a: clean
${CC} ${GMP_PATH} ${GMP_FLAGS} -c s21_*.c
ar rc $(PROJECTNAME).a s21_*.o
ranlib $(PROJECTNAME).a
test: $(PROJECTNAME).a
${CC} ${GMP_FLAGS} tests.c $(PROJECTNAME).a $(TEST_FLAGS) -o test
./test
gcov_report: clean
@${CC} ${GMP_FLAGS} $(GCOVFLAGS) s21_*.c tests.c $(TEST_FLAGS) -o test_report $(LIBS)
@./test_report
@lcov -t test_report -o test.info -c -d .
@genhtml -o report test.info
@open ./report/index-sort-f.html
rebuild: clean all
clean:
-rm -rf $(PROJECTNAME)
-rm -rf *.gcda
-rm -rf *.gcno
-rm -rf *.a
-rm -rf *.o
-rm -rf test
-rm -rf test_report
-rm -rf test.info
-rm -rf report
clear
clang:
clang-format --style=Google -n *.c *.h
clang-format --style=Google -i *.c *.h
GPT say to replace arguments but it doesnot work
test: $(PROJECTNAME).a ${CC} tests.c $(PROJECTNAME).a $(TEST_FLAGS) -o test ${GMP_PATH} ${GMP_FLAGS} ./test
-Wl,-no_pie also doesnot work
try to replace arguments add -Wl,-no_pie om mac this code work good but linux doesnot work. I think Linux try to find library by default adress. I ca use only static library in this project