qt561源码编译
㈠ 【求助】QT5.2.1源码编译有出错,提示incomplete type
加上 #include <QApplication>
incomplete type说明当前C++文件中没有定义QApplication类型,该类型应当在QApplication文件中被定义。,希望以后更细心一点。如果还出错,检查pro文件中是否有core和gui模块。
㈡ Qt下如何编译库
一般分为动态库和静态库,方法分别如下:
一.
静态库的生成
1.
测试目录:
lib
2.
源码文件名:
mywindow.h,
mywindow.cpp
3.
编写项目文件:
mywindow.pro
注意两点:
TEMPLATE
=
lib
CONFIG
+=
staticlib
4.
生成Makefile:
qmake
mywindow.pro
5.
编译生成静态库libmywindow.a
make
二.
静态库的使用
1.
测试目录:
test
2.
将mywindow.h与libmywindow.a拷贝至test目录下
3.
编写main.cpp,
包含头文件mywindow.h,
并调用MyWindow类
4.
编写项目文件:
test.pro
注意加上库路径与库文件名:
LIBS
+=
-L
./
-lmywindow
5.
生成Makefile:
qmake
test.pro
6.
编译:
make
7.
运行:
./test
三.
动态库的生成
动态库编译基本和静态库类似,需要将上述将要进行编译的项目文件.pro中下面这行去掉
CONFIG
+=
staticlib
按上述操作编译完后就可以得到以lib开头并且.so*
结尾动态库文件,一般有多个。
㈢ 拿到了一份前辈的QT源码,打算重新编译一下,出现如下错误信息,有大神知道什么原因,怎么破解吗
估计你不满足他编译设置条件,错误说/MP应该是一个文件或者目录,但是并不存在
㈣ linux下执行qt程序怎么编译运行
qmake -project? 已经有.pro文件了! 直接运行qmake或者qmake snake.pro或qmake -makefile snake.pro.
重新解压,按以下步骤做:
$ qmake
$ make
找到可执行文件(不是.o, 没后缀的), 一般如果snake.pro中没设置TARGET,默认生成的可执行文件为snake,输入
.$ /snake
㈤ 讨论上Windows平台怎么编译Qt5
Qt5的编译官方有一篇wiki:http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git
简要的总结下我的体会,欢迎补充完善、批评指正。
1.First clone the top-level qt5 git repository:
git clone git://gitorious.org/qt/qt5.git qt5
这一行不用说了,自然是将Qt5的代码克隆。不过,如果你只是初次克隆Qt5的代码,会很惊讶:为何克隆后的代码只有十几MB?
原来,Qt5已经实现了Qt的模块化,详见:http://labs.qt.nokia.com/2011/05/12/qt-moles-maturity-level-the-list/
所以可以在克隆得到的Qt5源码根目录下看到:.gitmoles 文件,其内容部分摘录如下:
[submole "qtbase"]
path = qtbase
url = git://gitorious.org/qt/qtbase.git
[submole "qtsvg"]
path = qtsvg
url = git://gitorious.org/qt/qtsvg.git
[submole "qtdeclarative"]
path = qtdeclarative
url = git://gitorious.org/qt/qtdeclarative.git
...
这时,有Git基础的朋友一定会想到:
git submole init
git submole update
不过,请不要这样做!
2. Following the README file we initialize the repository. This clones the various sub-moles of Qt5:
./init-repository
这是一个perl脚本。如果是在msys-git下,会发现Perl的版本不够。
我们需要安装一个Windows版本的Perl:http://www.activestate.com/activeperl/downloads
安装好以后,Perl就添加到PATH环境变量中去了。
在MSVC的控制台下执行:
perl init-repository --help
注意,不是直接执行init-repository,要用perl来执行它。看看帮助:大致了解下有哪些功能。
3. 注意它的三个小提示:
Hint1: If you’re going to contribute to Qt 5, you’ll need to pass the —codereview-username <Jira/Gerrit username> option to set up a “gerrit” remote for all the sub-moles.
Hint2: If you’re having problems downloading the webkit repository (which is quite big), you can pass —no-webkit.
Hint3: If you’re behind a firewall, pass —http
4. 我的方法:
perl init-repository -f --codereview-username loaden
这样就可以实现子模块的批处理了。特别要注意的是:在处理这些子模块时,其实是git clone了这些子模块,以致于他们可以独立使用。在qt5\qtbase目录下可以找到.git目录。
这与git submole update的结果是不一样的!!
同时我使用了codereview的用户名,是为了可以创建一个名为gerrit的远程仓库,可以将贡献的代码推送进去,类似:
git push gerrit HEAD:refs/for/master
5. 源码下载是非常慢的,因为QtWebkit达到了1.7GB。源码下载完成后,进入Qt5源码目录,配置环境变量:
set PATH=%CD%\qtbase\bin;%PATH%
之后echo看一下结果是否正确:
echo %PATH%
6. 建议直接在Qt5的源码目录下执行配置!
configure -confirm-license -opensource -release -shared -platform win32-msvc2010 -fast -no-stl -no-qt3support -nomake examples -nomake demos -nomake tests
7. 编译全部模块,直接执行nmake就可以了。如果只编译一个模块,可以这样:
nmake mole-qtbase
双击打开Qt5目录下的Makefile文件,可以看到有这些模块:
SUBTARGETS = \
mole-qtbase \
mole-qtsvg \
mole-qtphonon \
mole-qtxmlpatterns \
mole-qtdeclarative \
mole-qttools \
mole-qttranslations \
mole-qtdoc \
mole-qlalr \
mole-qtqa \
mole-qtlocation \
mole-qtactiveqt \
mole-qtsensors \
mole-qtsystems \
mole-qtmultimedia \
mole-qtfeedback \
mole-qtquick3d \
mole-qtdocgallery \
mole-qtpim \
mole-qtconnectivity \
mole-qtwayland \
mole-qtjsondb \
sub-qtwebkit-pri \
mole-qtwebkit-examples-and-demos
㈥ qt5.4 源码编译安装问题
在配置的时候加上 -nodbus,希望采纳,因为我编译的时候也遇到了,加上之后就好了。
㈦ ubuntu怎么编译qt5源代码
以下是编译QT源码的基本步骤:
1.源代码的获取 , 最新的是4.8.2版本。
2.解压代码
输入指令: tar zxvf qt-everywhere-opensource-src-4.8.2.tar.gz,解压出QT源代码。
3.执行./config生成makefile
输入指令: ./config
下面会出现提示,是使用the Commercial Edition还是Open Source Edition。
选择”o”,接着会出现一些提示关于license的信息,选择”yes”。
4.编译QT
等在Ubuntu中顺利下载了缺失的那3个lib后。再次重复第三步的 ./configure指令。
输入指令: make,
然后便可以顺利地生成Makefile文件。
5.安装QT
运行指令: sudo make install,需要几分钟的时间,系统会默认将Qt安装到目录:/usr/local/Trolltech/Qt-4.8.2。
验证安装完成:运行/usr/local/Trolltech/Qt-4.8.2/bin/designer,如果能够正常启动designer,则说明Qt已经安装好了。
6.设置环境变量
7.测试环境变量
