简体   繁体   中英

Compile Qt5 code without qmake

I want to write a C++ program that includes Qt5 code (but also boost library etc.). 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. In the tutorials I read there is a command called

qmake

for generating a makefile. But I want to generate the makefile with autotools.

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.

My question is: How to use autotools for Qt5? A discussion about the pros and cons of autotools vs. qmake is also welcome.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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