今天我想用 Makefile 编译我的项目(我在 Ubuntu 17 中),但我有一个非常大的问题:
/usr/bin/ld: ./lib/my/libgnl.a(gnl.o): 重定位 R_X86_64_32S 反对 `.bss' 在制作共享对象时不能使用;重新编译 avec -fPIC /usr/bin/ld : échec de l'édition de liens finale : Section non-représentable sur la sortie collect2: error: ld returned 1 exit status Makefile:52 : la recette pour la cible « mysh » a échouée制作:*** [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