你好,我想创建一个Qt5项目使用Qt-creator,并希望使用mpfr/gmp,所以我需要如何配置该项目。
因为如果我编译,我会得到这些错误:
#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();
}输出:
error: undefined reference to `mpfr_inits2'但在代码块上,我添加了包含路径和库路径,并将标志-lgmp -lmpfr添加到编译器中,运行良好。
发布于 2020-06-05 17:34:05
在QtCreator中,打开项目的.pro文件并附加以下行:
unix: LIBS += -lmpfr -lgmp或者,您也可以使用UI来完成此操作:在“项目”列表中,右键单击您的项目,选择“添加库”>“系统库”。在“库文件”字段中添加例如/usr/lib/mpfr.so。然后,QtCreator会将其转换为-lmpfr,如“摘要”视图中所示。重复这些步骤以添加/usr/lib/libgmp.so。


https://stackoverflow.com/questions/60921206
复制相似问题