library.h:
#ifndef INC_2SEM_LIBRARY_H
#define INC_2SEM_LIBRARY_H
#include <stdio.h>
#include <malloc.h>
typedef struct
{
int quantity;
int *val;
} stack;
void push(stack *s, int x);
int pop(stack *s);
#endif //INC_2SEM_LIBRARY_H
library.c:
#include "library.h"
void push(stack *s, int x)
{
if (!s->quantity){
s->val=realloc(s->val,1);
s->val[s->quantity++] = x;
}
else {
s->val[s->quantity++] = x;
s->val = realloc(s->val, s->quantity);
}
}
int pop(stack *s)
{ if (!s->quantity)
return s->val[--s->quantity];
}
main.c:
#include <stdio.h>
#include "library.h"
int main() {
stack q;
push(&q,12);
//printf("%i",pop(&q));
return 0;
}
ошибки:
CMakeFiles/2sem_main.dir/main.c.o: In function `main':
/home/ivan/CLionProjects/2sem_main/main.c:5: undefined reference to `push'
collect2: error: ld returned 1 exit status
CMakeFiles/2sem_main.dir/build.make:83: recipe for target '2sem_main' failed
make[3]: *** [2sem_main] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/2sem_main.dir/all' failed
make[2]: *** [CMakeFiles/2sem_main.dir/all] Error 2
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/2sem_main.dir/rule' failed
make[1]: *** [CMakeFiles/2sem_main.dir/rule] Error 2
Makefile:118: recipe for target '2sem_main' failed
make: *** [2sem_main] Error 2
Ошибки похожие ибо занес файлы в новый проект.
Не корректно работает пользовательская библиотека. Вылазят ошибки. Подскажите что делать?