Recently, an error occurred while using qmake, prolactin, and TEMPLATE = subdir. Record for later viewing.
Project Structure:
- project.pro
- main\
- \__ main.pro
- lib\
- \__ lib.pro
Project. pro:
- TEMPLATE = subdirs
- SUBDIRS = main lib
- main.depends = lib
In main. pro, there is a sentence:
- CONFIG += link_prl
Lib. pro has the following sentence:
- CONFIG += create_prl
The error is:
1. lib files and dynamic libraries are generated successfully.
2. The main project does not read the content in the top 5.
At first, I thought it was the issue of ld during the connection period. After practice, I ruled out this possibility.
Finally, I found something strange in Makefile. Is the Makefile file corresponding to project. pro:
- sub-main: main/$(MAKEFILE) sub-lib
- cd main/ && $(MAKE) -f $(MAKEFILE)
That is to say,
Fact 1: main first generates its own Makefile from main. pro, and then make sub-lib target. |
At the same time, we know that
Fact 2: prolactin is read in the qmake stage. |
Therefore, we can conclude that:
Inference 1: when the main qmake is executed, the library object's top 5 files and dynamic library files are not yet generated. This will inevitably cause the main to be unable to read the library generated by lib. |
In fact, the final solution is helpless. In the project. pro, the order of main and lib is reversed and then compiled. Everything is normal.
This article is from the "elephant_liu" blog, please be sure to keep this source http://elephantliu.blog.51cto.com/1107116/835870