Qt open source project SerialTool locally compiled the whole process

background:

That day saw someone on the Internet to share a Qt project's practiced hand: QserialTool, the interface looks very friendly (good-looking than sscom lot), I wanted to download it to learn about other people's thing - pressing the connection went github, download experience experience (explained above general looked at me, did not look carefully).

Explain to me the compiler environment: Qt5.9.8, win10,64 bit, mingw32 compiler

process:

1, environment variables

After downloading this, I wanted to compile it, my computer installed two versions of Qt, is a 5.5.1, 5.9.8 a is, Creator versions are not the same, because the 5.9.8 version has been integrated with the Creator . The company is a project with 5.5.1, their play when that version too old, with 5.9.8. I remember seeing QserialTool It says the properties required C ++ 11, I first changed the environment variable. qmake and path mingw32-make version 5.9.8 are replaced by the path, look at the screenshot:

The above is qmake and minggw32-make environment variable settings, in order to prevent accidents, I could not even order path PATH which are rearranged, put up all the rows 5.9.8, there are screenshots:

2, began to compile

Set up these environmental variables, I will open my Qt for the first time need to configure the Creator to open, do not hesitate to choose the configuration of 5.9.8 (I have 5.5.1 configuration, the flag is clear), configuration well, after I was wondering compile a try.

The first compilation error, missing files: Qsci / qsciscintilla.h, which I never used (laughed ha), I went to search for a moment, can be a highlight of a text edit control, say very good online a control that, listen, I wanted to try ~ (* ^ ▽ ^ *)

3.QSciscintilla control installation

I went to download this control qsciscintilla, the following is a screenshot:

Download link to share: https://riverbankcomputing.com/software/qscintilla/download

这个控件下载了之后,我就寻思编译一下,我看见一个博客写的很详细,跟我的环境也很类似的,感谢作者!分享一下:

QsciScintilla的使用方法总结(一个很好用的文本编辑器库):

https://blog.csdn.net/qq_19528953/article/details/52659109

我就按照这个博客说的执行了下面的操作(前提是要在QsciScintilla的qt4qt5文件夹下运行命令窗口,然后运行下面的指令):

qmake qscintilla.pro     #使用qmake工具生成makefile文件
mingw32-make             #使用Qt5.7 MinGW版本自带的make工具按照makefile里面的定义的方式编译qscintilla的源文件
mingw32-make install     #将编译生成的库整合到自己的Qt源文件中

编译过程异常顺利,我寻思编译好了可以用了吧?

4、第二次编译失败

这次失败有点出乎意料,因为我用release运行没有任何问题,用debug就不行,报错的样子是这样的:

第一个错误QIODeviceXXXXXX好解决,我以前遇到过,也知道那个语句干嘛的,就是开启TXT模式,具体的可以看着链接:

https://blog.csdn.net/yimuta9538/article/details/103769756

第二个错误Qt QWidget : Must construct a Qapplication before a Qwidget,我以前没遇到过,这个感觉好像工程里面文件有问题呀,没有构建Qapplication就用了Qwidget

5、错误解决

第一个错误直接去把代码中的语句屏蔽掉,没啥太大影响,回头需要用,就给它换个地方得了。

关于第二个错误,我需要去认真查找原因了,先去搜索了一下,找了网上的几乎全部的相关资料得出两个原因:

第一个是真的就如字面意思所说;

第二个是说release库和debug库调用混乱。

我不信是第一个原因,要是这样的话,作者肯定跟我遇到同样的错误;而且,我也确实刚刚添加了一个控件的静态库呀,所以,我猜是第二个原因。

实际上,我们还有第二个线索,右键点击Qt报错那里,选择显示原始输出,我就看到了下面的情况:

它其实是找不到lqscintilla2_qt5d这个库了,我用everything搜索了一下我的电脑,还真没有,去掉字母“d”,找到一个,在release文件夹里面,我估摸着是因为我刚才编译的时候用的是release模式,所以只有realease库,没有debug库,我去release文件夹对应的debug文件夹里瞅了瞅,空的??!! ̄□ ̄||

那我就得想办法给他用debug模式编一下,怎么编呢?实际上,我走了不少弯路,修改了pro配置文件,还是不行,debug里面还是空的。欠抽的我就灰溜溜的去GitHub上面瞅瞅项目说明吧,说不定能有点线索。感谢作者,链接奉上:

https://github.com/Skiars/SerialTool

然后我就懵逼了。。。下面是截图:

天哪!写的这么详细!我刚才都干了多少蠢事情??!!我是谁?我在哪儿?o(╥﹏╥)o

我内心百感交集,只能在qt4qt5文件夹的命令窗口上敲下了如下代码:

qmake CONFIG+=debug
mingw32-make
mingw32-make install

运行之后,我又一次回到Creator界面。

6、结果

看见上面这个图了吗?debug和release都可以完美运行了,我可能是蜘蛛。。。。┭┮﹏┭┮

最后

不得不给SerialTool的作者点个赞赞赞!软件写的好,说明写的又这么详细!真心感谢~

好像是下面的大佬写的。。。。他自己在论坛说的,不是我瞎说的。

 

最后,希望大家做啥事情,用啥软件都先看看说明书!说明书!说明书!说明书!说明书!说明书!

发布了11 篇原创文章 · 获赞 9 · 访问量 670

Guess you like

Origin blog.csdn.net/yimuta9538/article/details/103885510