I'm doing a program in c in which I have two libraries, vector.h and entero.h, this second created from vector.h. In the main I use the functions of the entire library.h, but I have a warning that says:
relocation truncated to fit: R_X86_64_PC32 against undefined symbol
in all functions that I use and the program does not compile. I have checked that the libraries are included in all the headers, and that all the names of the functions, as well as the parameters, are correct. What can this error be caused?
The code for the libraries is as follows:
//vector.h
typedef int TELEMENTO;
typedef void * vectorP;
void crear(vectorP *v1,unsigned long int tam1);
void asignar(vectorP *v1,unsigned long int posicion, TELEMENTO valor);
void liberar(vectorP *v1);
TELEMENTO recuperar(vectorP v1, unsigned long int posicion);
unsigned long int tamanho(vectorP v1);
integer.h
#include "vector.h"
typedef void *entero;
void creaEnteroLargo(entero *v1, unsigned long int tam1, int signo);
void asignarEntero(entero *v1,unsigned long int posicion, TELEMENTO valor);
void liberarEntero(entero *v1);
TELEMENTO recuperarEntero(entero v1, unsigned long int posicion);
unsigned long int tamanhoEnt(entero v1);
And in the entero.c, in addition to the implemented functions, I have the following:
#include <stdio.h>
#include <stdlib.h>
#include "vector.h"
typedef struct {
TELEMENTO *cifras;
int signo;
unsigned long int tam;
}STENTERO;
typedef STENTERO *entero;
The code of the function recoventente is as follows:
TELEMENTO recuperarEntero(entero v1, unsigned long int posicion){
if (posicion >= 0 && posicion < v1->tam)
{
return v1->cifras[posicion];
}
return 0;
}
The compiler that I use is gcc version 5.4.0
This error was given to me by Netbeans in Windows, but when compiling in Linux I get a similar error:
reference to 'recoverInteger' without defining
And so with all the functions. To compile I use a makefile with the following:
CC = gcc -Wall
HEADER_FILES_DIR = ./headerFiles
INCLUDES = -I $(HEADER_FILES_DIR)
MAIN = ejecutable
SRCS = main.c entero.c vector.c
OBJS = $(SRCS:.c=.o)
DEPS = $(HEADER_FILES_DIR)/entero.h $(HEADER_FILES_DIR)/vector.h
$(MAIN): $(OBJS)
$(CC) -o $(MAIN) $(OBJS) $(LIBS)
%.o: %.c $(DEPS)
$(CC) -c $< $(INCLUDES)