问题
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