I am trying compile to dynamic libary, main.c:
`#include <stdio.h>
#include <stdlib.h>
#include <math_utils.h>
int main(){
int x,y;
scanf("%i%i", &x, &y);
printf("%i\n%i", gcd(x, y), lcm(x, y));
}`
math_utils.h
#pragma once
int gcd(int x, int y);
int lcm(int x, int y);
math_utils.c
#include "math_utils.h"
int gcd(int x, int y){
int i;
for(i = smaller(x,y); i>0; --i){
if(x%i==0 && y%i==0){
return i;
}
}
return 0;
}
int lcm(int x, int y){
int big = bigger(x, y);
int small = smaller(x, y);
int iteration = 1;
while((big*iteration)%small!=0){
++iteration;
}
return big*iteration;
}
int smaller(int x, int y){
if(x<y){
return x;
}
return y;
}
int bigger(int x, int y){
if(x>y){
return x;
}
return y;
}
commands in the console:
- gcc -fPIC -c math_utils.c
- gcc -shared -o libmath.dll math_utils.o
- gcc -o app main.c libmath.dll
After last i got it error: main.c:3:10: fatal error: math_utils.h: No such file or directory #include <math_utils.h>
Can anyone explain me ,why my main dont see math.. Thanks for every answer.
All files are in one folder
I am expecting to have dynamic library