一.编译库文件
1. 创建library项目
2. 选择要配置的编译器
3. 把自动生成的源码都移除:(右键单击,选择 remove)
4
4. 导入库源码
把源码拷贝到项目目录下(.pro 文件所在的目录)
5. 修改 configure.js 文件
var srcDir = "..";
修改为:
//这里修改成你自己的src目录就行
var srcDir = "E:\\QT_Project\\study\\modbusQN\\libmodbus-3.1.6\\src";
6. 双击 configure.js,然后生成 config.h
- 把生成的 config.h 拷贝到上一级目录 src 目录下。
7. 把项目源码导入到项目中:
8. 修改pro文件
QT -= gui core
#去除 core 模块
TEMPLATE = lib
DEFINES += MODBUSQN_LIBRARY
#配置为动态库
CONFIG += c++11 dll shared
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS