如何在Qt-Creator中正确使用mpfr/gmp? [英] How to use mpfr/gmp in Qt-Creator properly?

查看:514
本文介绍了如何在Qt-Creator中正确使用mpfr/gmp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想使用Qt-creator创建一个Qt5项目,并想使用mpfr/gmp,所以我需要如何配置该项目.

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();
}

输出:

 error: undefined reference to `mpfr_inits2'

但是在代码块上,我添加了include路径和库路径,并向编译器添加了-lgmp -lmpfr标志,并且工作正常.

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

推荐答案

在QtCreator中,打开项目的.pro文件并添加以下行:

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

unix: LIBS += -lmpfr -lgmp

或者,您也可以使用UI来执行此操作:在项目"列表中,右键单击您的项目,选择添加库">系统库".在库文件"字段中添加例如/usr/lib/mpfr.so.然后,QtCreator将其转换为-lmpfr,如摘要"视图中所示.重复这些步骤以添加/usr/lib/libgmp.so.

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.

这篇关于如何在Qt-Creator中正确使用mpfr/gmp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆