简体   繁体   English

不使用qmake编译Qt5代码

[英]Compile Qt5 code without qmake

I want to write a C++ program that includes Qt5 code (but also boost library etc.). 我想编写一个包含Qt5代码的C ++程序(但也包括boost库等)。 In order to compile the program I want to use the commands: 为了编译程序,我想使用以下命令:

./autogen.sh
./configure
make
make install

But I don't know how to compile the Qt5 part of my program. 但是我不知道如何编译程序的Qt5部分。 In the tutorials I read there is a command called 在我阅读的教程中,有一个命令叫做

qmake

for generating a makefile. 用于生成makefile。 But I want to generate the makefile with autotools. 但是我想用自动工具生成makefile。

I know that this is possible, because eg the Bitcoin Core source code has Qt5 code (for the user interface window) and you don't use qmake for compiling this source code, but autotools. 我知道这是可能的,因为例如Bitcoin Core源代码具有Qt5代码(用于用户界面窗口),并且您不使用qmake来编译此源代码,而是使用自动工具。

My question is: How to use autotools for Qt5? 我的问题是:如何在Qt5中使用自动工具? A discussion about the pros and cons of autotools vs. qmake is also welcome. 也欢迎讨论自动工具与qmake的优缺点。

First you need m4 configure macros to detect Qt5, moc etc. Just borrowing them from some existing software like the one you mention is probably ok for a start. 首先,您需要m4 configure宏来检测Qt5,moc等。只需从现有软件(例如您提到的软件)中借用它们就可以了。

These macros will set the right variables which you use to compile and link your program. 这些宏将设置用于编译和链接程序的正确变量。

If you are starting from zero consider using CMake instead of autotools as recommended in the comments. 如果您从零开始,请考虑使用CMake代替注释中建议的自动工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM