I am trying to compile the code below:

int main()
char dateString[20], timeString[20];
struct tm *tmptr;
time_t t;
t = time(NULL);
tmptr = localtime(NULL);
printf("%d ---%s\n",tmptr,tmptr);
return 0;

Header.h has :


When compiling this code, I get an error saying that:

/usr/lib/gcc/i686-linux-gnu/5/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory

Concluding that it is trying to tell me that, the library file is missing, I went through the previous threads and tried updating gcc compiler but I still see this error. Can somebody please help me to fix it?


That file is provided by the libmpfr4 package, which can be installed by opening a terminal (press Ctrl+Alt+T) and running:

sudo apt-get update
sudo apt-get install libmpfr4

If it says the package is already installed, you can try:

sudo apt-get install --reinstall libmpfr4
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.