How to use gmp-mpir-mpfr in eclipse correctly?

点点圈 提交于 2020-12-15 06:58:50

问题


I've managed to to use mpfr-mpir-gmp in CodeBlocks but I want to in eclipse C++:

When I compile the code it compiles and build but if I run the project it says: "error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory".

So can anyone show me how to configure eclipse to use gmp-mpifr-mpir correctly?

  • If I compile from a terminal:

    g++ -lmpir -lmpfr -lgmp myEclpiseMPFRMPIRproj.cpp
    

then :

./a.out

It works fine and doesn't complain about the same problem. So I think I don't know how to pass those flags -lgmp, -lmpir -lmpfr.

Thank you.


回答1:


I've figured it out after thousands of attempts without giving up. I am happy to share it for someone who may face the same problem:

When I've built and installed "gmp, mpfr, mpir" I've used sudo make install so the library is in /usr/local thus when I create a project with Eclipse-CDT everything is there only I add the flag to the linker:

 Project->properties->C/C++ Build->Settings->GCC C++ Linker->Command and add:

g++ -lgmp -lmpir -lmpfr
  • Apply and Close. Now build and run. It works fine!

N.B: The problems I've faced already because I've add the library paths and files and include paths so I've removed them all.



来源:https://stackoverflow.com/questions/60950890/how-to-use-gmp-mpir-mpfr-in-eclipse-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!