Results 1 to 5 of 5

Thread: compile with minGW ??

  1. #1
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default compile with minGW ??

    Hi,

    I'd like to know how to copile a simple QT program such as the one below using minGW command line. I've never used command line before and I'm very new to Qt.
    More specifically:
    1. Do I need to make a "hello.pro" file and subsequently a "makefile" (with qmake) for
    this simple project
    2. How do you then use command line? What do you type in?
    When I do C:\Qt\4.3.2\myfolder> g++ -c hello.cpp
    the copiler complains just about every Qt-related stuff in the program.
    I don't know how to compile things that are not pure C++ and involve linking more
    than one file (especially if the file is a makefile).

    // hello.cpp
    #include <QApplication>
    #include <QPushButton>

    int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QPushButton hello("Hello");
    hello.show();
    return app.exec();
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compile with minGW ??

    Even if you are familiar with command line tools, you should use qmake. It's pretty straightforward:
    C:\...> qmake
    C:\...> make
    If you don't have a .pro file, you can invoke "qmake -project" in the directory with your sources to generate one.

  3. #3
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: compile with minGW ??

    Hi Jacek,

    I see that Eric is trying to figure out exacly the same thing as me.
    Once you have your makefile, how do you then use it in your command line? What's the syntax? Where do you put the name of the makefile when you compile.

    Thanks again Jacek!

    Tommy

  4. #4
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: compile with minGW ??

    Quote Originally Posted by tommy View Post
    Hi Jacek,

    I see that Eric is trying to figure out exacly the same thing as me.
    Once you have your makefile, how do you then use it in your command line? What's the syntax? Where do you put the name of the makefile when you compile.

    Thanks again Jacek!

    Tommy
    The make command looks for a file named "Makefile" by default. You can however specify other makefiles with the -f option. If you add source files you will generally want to update your project file. When I start a project using QT I create all of my source files as empty skeletons. Running the following should provide you with a compiled project.

    Qt Code:
    1. qmake -project // generates your project file
    2. qmake // generates your make file
    3. make // builds your app
    To copy to clipboard, switch view to plain text mode 

    Any time you change your source (ie/ save) run make. If you add files, either manually update the PROJECTNAME.pro file (preferred esp. if you start working with plugins), or rerun all 3 commands. I believe on Windows you will also need to ensure the bin folder in QT is located in your path otherwise it won't find the required DLL's. Your programs exe will generally be placed in the "release" folder.

    Regards,

    Nate

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compile with minGW ??

    Quote Originally Posted by tommy View Post
    Once you have your makefile, how do you then use it in your command line? What's the syntax? Where do you put the name of the makefile when you compile.
    By default make looks for a file called "Makefile" in the current directory, but you can also use -f option to tell it which file to read (for example "make -f Makefile.Release").

Similar Threads

  1. using libcurl in QT with Mingw in Windows
    By ct in forum Qt Programming
    Replies: 18
    Last Post: 23rd January 2012, 01:41
  2. Use VC2005 to compile Qt program (4.3.0)
    By firegun9 in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2007, 16:04
  3. Replies: 7
    Last Post: 24th March 2007, 13:53
  4. QtNetwork error by compile MingW qt4.2
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 15:09
  5. Problem to compile with MinGW + Qt 4 + winpcap
    By jlbrd in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2006, 16:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.