在安装目录之外的目录中编译 Qt 项目
我已经使用 OpenCV 开发一个项目一段时间了,准备升级我的用户界面,从使用 cvWaitKey()
获取按键并使用轨迹栏模拟按钮。哈。所以我决定使用Qt。
我想继续在我一直使用的同一目录中进行开发,当然,该目录位于 Qt 安装目录 C:\Qt\2010.05\qt 之外。使用“Qt 命令提示符”,我可以在 C:\Qt\2010.05\qt 内外的目录中编译 Hello Notepad 示例,即 C:\Qt\2010.05\qt\abc 和 C:\Qt \2010.05\abc。
但是,虽然在 C:\ ... \qt 下编译会在调试和发布目录中生成可执行文件,但在其外部编译只会生成调试可执行文件以及 .o 文件(目标代码?)。我使用 WinMerge 进行了一些比较,发现以下几行(除其他外)在两个 makefile 中有所不同(使用 qmake -project
生成,然后使用 qmake
生成):
Inside qt\
first: all
install: debug-install release-install
uninstall: debug-uninstall release-uninstall
在 qt\ 之外,
first: debug
install: debug-install
uninstall: debug-uninstall
这显然是问题所在(由 qmake -project
生成的 .pro 文件仅在时间戳上有所不同)。我确信对于导致此问题的原因有一个简单的答案...我希望有一个简单的答案来解决我如何解决这个问题。另外,我打算使用 QtCreator 一些;希望 IDE 的解决方案与命令行编译器的解决方案相同。
谢谢!
诺兰
附注:我不认为这是同一个问题: Qmake 不支持源目录下的构建目录 ...无论如何,我不确定我是否理解答案。
I've been working on a project using OpenCV for a while, and am ready to upgrade my user interface from using cvWaitKey()
to get key presses and emulating buttons with trackbars. Ha. So I've decided to use Qt.
I'd like to continue developing in the same directory I've been using, which is, of course, outside of the Qt install directory, C:\Qt\2010.05\qt. Using the "Qt Command Prompt", I'm able to compile the Hello Notepad example in directories both in and out of C:\Qt\2010.05\qt, namely C:\Qt\2010.05\qt\abc and C:\Qt\2010.05\abc.
However, while compiling under C:\ ... \qt produces executables in both the debug and release directories, compiling outside of it only produces the debug executable, along with a .o file (object code?). I did some comparisons using WinMerge, and found that the following lines (among others) differ in the two makefiles (generated using qmake -project
and then qmake
):
Inside qt\
first: all
install: debug-install release-install
uninstall: debug-uninstall release-uninstall
Outside qt\
first: debug
install: debug-install
uninstall: debug-uninstall
That's clearly the problem (the .pro files generated by qmake -project
differ only in timestamp). I'm sure there's an easy answer out there to what's causing this... I hope there's an easy answer to how I can work around it. Also, I intend to use QtCreator some; hopefully the solution is the same for the IDE as the Command-Line compiler.
Thanks!
Nolan
p.s.: I don't think this is the same issue: Qmake does not support build directories below the source directory ...in any case, I'm not sure I understand the answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够添加
到 .pro 文件中,以构建发布目标。还有
iirc。
QtCreator 有一个用于在构建目标之间切换的 GUI 元素,如果您发现需要经常来回切换,您可以尝试使用该应用程序打开 .pro。
You should be able to add
to your .pro file, to build for release target. There's also
iirc.
QtCreator has a GUI element for toggling between build targets, you might try opening the .pro with that application if you find you need to switch back and forth often.