今天我想用Makefile编译我的项目(im在Ubuntu 17中),但我有一个非常大的问题:
/ usr / bin / ld:./ lib / my / libgnl.a(gnl.o):在创建共享对象时,不能使用针对`.bss'的重定位R_X86_64_32S; recompiléavec-fPIC / usr / bin / ld:échecdel'éditiondeliens finale:section un-représentablesurla sortie collect2:错误:ld返回1退出状态 Makefile:52:la recette pour la cible«mysh»aéchouée make:*** [mysh] Erreur 1
我一直试图找到一个多小时的解决方案,但现在我开始失去它。 (是的,我的Makefile中已经有-fPIC标志) 你能帮帮我吗?
有我的Makefile:MAKEFILE part1 MAKEFILE part2
SRC = source/utils/char_utils.c \
source/utils/clean_str.c \
source/utils/check_redir.c \
source/utils/count_words.c \
source/utils/my_get_array.c \
source/utils/my_get_number.c \
source/utils/my_strncat.c \
source/utils/my_strcat.c \
source/utils/my_strcmp.c \
source/utils/my_strdup.c \
source/utils/my_strncmp.c \
source/utils/my_strcpy.c \
source/utils/my_str_to_wordtab.c \
source/core/check_spaces.c \
source/core/error_exec.c \
source/core/handle_signals.c
source/core/my_builtin.c \
source/core/my_cd.c \
source/core/my_commas.c \
source/core/my_env.c \
source/core/my_exec.c \
source/core/my_exit.c \
source/core/my_getenv.c \
source/core/my_prompt.c \
source/core/my_pipe.c \
source/core/my_d_redir_left.c \
source/core/my_d_redir_right.c \
source/core/my_redir_left.c \
source/core/my_redir_right.c \
source/core/my_parsing.c \
source/core/my_setenv.c \
source/core/my_unsetenv.c \
source/core/my_shell.c \
source/core/main.c
OBJ = $(SRC:.c=.o)
NAME = mysh
CFLAGS = -fPIC -g3 -Wall -Wextra -Iinclude
all: $(NAME)
$(NAME): $(OBJ)
gcc $(CFLAGS) -o $(NAME) $(SRC) -lgnl -L./lib/my
clean:
rm -f $(OBJ)
fclean: clean
rm -f $(NAME)
find -name "*~" -delete
find -name "#*#" -delete
find -name "vgcore*" -delete
re: fclean all
.PHONY: fclean clean all re