How to use mpfr/gmp in Qt-Creator properly?

╄→гoц情女王★ 提交于 2020-07-22 07:49:23

问题


Hello I want to create a Qt5 project using Qt-creator and want to use mpfr/gmp so I need how to configure the project.

because if i compile I get these errors:

#include "mainwindow.h"

#include <QApplication>
#include <stdio.h>
#include <gmp.h>
#include <mpfr.h>



int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    mpfr_t x, y, z, t;
    mpfr_inits2 (256, x, y, z, t, (mpfr_ptr) 0);

    return a.exec();
}

The output:

 error: undefined reference to `mpfr_inits2'

But on codeblocks I add the include path and library path and add the flags -lgmp -lmpfr to the compiler and works fine.


回答1:


In QtCreator, open the .pro file of your project and append the following line:

unix: LIBS += -lmpfr -lgmp

Alternatively, you can also use the UI to do this: In the "Projects" list, right-click on your project, select "Add library" > "System Library". In the "Library file" field add e.g. /usr/lib/mpfr.so. QtCreator will then turn this into -lmpfr, as shown in the "Summary" view. Repeat these steps to add /usr/lib/libgmp.so as well.



来源:https://stackoverflow.com/questions/60921206/how-to-use-mpfr-gmp-in-qt-creator-properly

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