简体   繁体   English

Qt项目的通用Makefile

[英]Generic Makefile for Qt Project

I'm currently workind on a project for my school. 我目前正在为我学校的一个项目工作。 It's a snake game which will work with 3 differents graphics. 这是一款蛇游戏,可以处理3种不同的图形。

It works fine, but I want to add a Qt touch in order to display a Window when the game is over. 它工作正常,但我想添加Qt触摸以在游戏结束时显示窗口。 I already built the window, but now I need to merge this with my project, and my project has to compile with a Makefile. 我已经构建了窗口,但是现在我需要将其与我的项目合并,并且我的项目必须使用Makefile进行编译。 The problem is that I don't know if I can build my project with a unique Makefile. 问题是我不知道是否可以使用唯一的Makefile来构建项目。 I usually use qmake -project, qmake, and make to build my Qt projects. 我通常使用qmake -project,qmake和make来构建我的Qt项目。

Thnks for your help 谢谢你的帮助

There is no universal Makefile , it will always vary depending on what platform you use, where Qt is installed, what Qt libraries you link and many other things. 没有通用的Makefile ,它总是会根据您使用的平台,安装Qt的位置,链接的Qt库以及许多其他因素而有所不同。

For this simple main.cpp : 对于这个简单的main.cpp

#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton button("Hello");
    button.show();

    return app.exec();
}

Makefile could be: Makefile可能是:

CC=g++
CFLAGS=-I. -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/qt4
LIBS=-lQtGui -lQtCore

app: main.cpp
    $(CC) $(CFLAGS) $(LIBS) $< -o $@

If you also need signals and slots, you need to add a separate target to Makefile to run moc . 如果还需要信号和插槽,则需要向Makefile添加一个单独的目标以运行moc Try to investigate what qmake generates and learn from it. 尝试调查qmake生成的内容并从中学习。

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

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