关于boost库的编译,请看https://www.cnblogs.com/HackerArt/p/10539516.html

网上可以查到很多介绍qt使用库文件的教程,但是大多都没有注意到,qt中支持设置环境变量这个特性。

这里我拿boost库来举例说明。

qt creator创建项目,设置boost库文件的引入。

将编译生成好的lib目录,添加到LIB或者Path,

boost库头文件不要添加到INCLUDE中,加到这里qt会提示不识别,

需要将boost库头文件添加到qt的pro配置文件中。

提示:boost源目录下的boost目录中的文件 就可以作为include头文件,不需要额外生成,

# Boost 1_69
# boost头文件目录
INCLUDEPATH += D:\boost\include

qt项目中添加测试代码

#include "MainWindow.h"
#include "ui_MainWindow.h" #include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <iostream>
#include <Windows.h>
#include <qdebug.h>
using namespace std; void TestBoost()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
//cout << "number: " << a << " " << b << endl;
//cout << "string: " << s0 << " " << s1 << endl;
//OutputDebugStringA(a);
qDebug() << a << b << endl;
qDebug() << s0.c_str() << s1.c_str() << endl;
//OutputDebugStringA(s1);
int c = 0;
try {
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e) {
//cout << e.what() << endl;
}
} MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this); TestBoost();
} MainWindow::~MainWindow()
{
delete ui;
}

清理,重新构建(如果没效果执行qmake)打开debugView查看输出

Qt中使用Boost库的更多相关文章

  1. 在Visual Sutdio 2017中使用boost库

    在Visual Sutdio 2017中使用boost库     转载 https://blog.csdn.net/u011054333/article/details/78648294 对C++有一 ...

  2. 在RedHat 7.2中安装boost库

    在RedHat 7.2中安装boost库 环境,其它版本类似 Redhat7.2 64bit boost 1.64.0 步骤 去 boost官网 下载想要版本的.tar.gz,如下图 解压tar -v ...

  3. Qt中使用Boost

    编译BOOST库 bjam stage --toolset=qcc --without-graph --without-graph_parallel --without-math --without- ...

  4. VS2012中使用Boost库的方法(超级简单)

    很不错的博客一定得看 http://my.csdn.net/caimouse 1.下载boost库 从http://www.boost.org上下载到目前最新的boost库,快速传送门:boost_1 ...

  5. QT中使用Glut库

    用Qt中的QGLWidget窗体类中是不包括glut工具库的,难怪在myGLWidget(在我的程序中是QGLWidget的派生类)中绘制实心球体是说“glutSolidSphere”: 找不到标识符 ...

  6. Qt中调用PolarSSL库(一)

    最近一直在学习SSL相关的知识,也是先了解理论相关的知识,主要是SSL相关的基本概念和连接建立过程,主要是基于PolarSSL开源库进行学习.学习完了之后就希望能给有所运用,就想用Qt写一个简单的程序 ...

  7. Qt中添加OpenCV库

    配置在Qt中的OpenCV,看了很多“教程”,最终成功.记一下过程. 本机配置: window7 32位系统: qt-opensource-windows-x86-mingw492-5.5.1: Op ...

  8. Qt中使用OpenCV库

    原地址:http://blog.sina.com.cn/s/blog_5c70dfc80100qwi3.html 心情真是好啊,曾经一度想放弃使用Qt加OpenCV进行数字图像处理了,幸好坚持住了,今 ...

  9. 在Qt中调用Mupdf库进行pdf显示

    2018.5.10 更新内存对齐说明 感谢知乎网友@孤独子狮 指出QImage处需要考虑内存对齐的问题.因为本人缺乏跨平台.图形库开发经验,所以在调试成功后就没有深入探究. 主要修改了QImage的构 ...

随机推荐

  1. js替换字符串中特殊字符

    var reg=/\\|\/|\?|\?|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\[|\]|\:|\:|\.|\^|\$|\!|\~|\` ...

  2. iphone手机怎么录屏 两种方法任你挑选

    iphone手机怎么录屏呢?苹果手机拥有独特的Airlay镜像投屏,AirPlay的工作原理是当iPhone或IPAD与支持AirPlay技术的硬件,比如Apple TV等设备处在同一个wife的情况 ...

  3. SD Consultant Year End Activities

    SD Consultant Year End Activities What are the year ending activities to be done for SAP SD?   S.No ...

  4. windows查看笔记本电池使用报告

    CMD 下 powercfg /batteryreport /output “C:\battery_report.html” powercfg 参数 /LIST./L          列出所有电源方 ...

  5. Loadrunner 脚本开发-利用loadrunner开发Windows Sockets协议脚本

    脚本开发-利用loadrunner开发Windows Sockets协议脚本 by:授客 QQ:1033553122 欢迎加入软件性能测试交流QQ群:7156436 实践举例 Socket服务端简单实 ...

  6. Android开发学习之RecyclerView

    1.在app/build.gradle中添加RecyclerView依赖 implementation 'com.android.support:recyclerview-v7:28.0.0' 注意依 ...

  7. 使用MUI/html5plus集成微信支付需要注意的几点问题

    1)需要在服务器根目录放上证书,从微信开放平台下载 2)客户端组件目录名一定要按照微信要求

  8. 华为ENSP进行evn实验,尚不完整,但已经有RT1、RT2、RT3、RT4了

    组网R1 -- CE12800  -- CE12800 --- R2 其中R1.R2是模拟VM的 R1的配置: interface GigabitEthernet0/0/0#interface Gig ...

  9. Symantec Backup Exec 2010 安装报 bad ELF interpreter: No such file or directory

    在64位的Red Hat Enterprise Linux Server release 6.6上安装Symantec Backup Exec 2010时, 遇到下面错误: # ./installra ...

  10. Android 闪烁动画

    import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animatio ...