I'm trying to make a kind of my_malloc.C but when I try to compile, this happened :
"/usr/bin/ld: block_addr.o: relocation R_X86_64_PC32 against symbol `baseb' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value"
Well, I search a lot in google, i read this topic :
"How do I share a variable between source files in c"
but this didn't solved my problem.
So, I share with you some piece of code.
First : the Makefile :
 CC      =       gcc -fPIC
 RM      =       rm -f
 NAME    =       libmy_malloc_$(HOSTTYPE).so
 SRCS    =       block_addr.c \
            block_ope.c \
            malloc.c \
            my_free.c
 OBJS    =       $(SRCS:.c=.o)
 all:            $(NAME)
 $(NAME):        $(OBJS)
            $(CC) -fPIC -shared -o $(NAME) $(OBJS)
 clean:
            $(RM) $(OBJS)
 fclean:         clean
            $(RM) $(NAME)
 re:             fclean all
.PHONY:         all clean fclean re
in my .h i have it :
extern void             *baseb;
and on my malloc.c :
void            *baseb;
void            *malloc(size_t size)
{
 t_memblock    b;
 t_memblock    last;
 size_t        s;
  baseb = NULL;
 ..
}
and I use "baseb" in other function of my program. I tried to declare "extern void *baseb;" on the begining of each files, but the compilation's error is still the same.
Can you help me ?
 
     
    