Results 1 to 9 of 9

Thread: I cannot compile project from command line

  1. #1
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default I cannot compile project from command line

    Hello,

    I am new to Qt therefore I installed everything by running QtSDK 1.2.1. I read this is the best choice for those who just get started. I am trying to make an application in Mac OS X 10.6.8. I am also quite new to Mac OS X. I have a pretty annoying problem regarding compiling a project. I made a test project with this source file:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[]) {
    4. QApplication app(argc, argv);
    5. QPushButton* button = new QPushButton("Hello_word");
    6. button->show();
    7. return app.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    It is weird because the project can be compiled if I use Build All from QtCreator's menu. However, I also tried to compile it from command line. I read that I need a .pro file which I have. I also read that I have to run qmake to build a makefile:
    Qt Code:
    1. qmake
    2. make
    To copy to clipboard, switch view to plain text mode 
    After this, my program should be ready to start. When I however try to run make with the Makefile, I get this message:

    ld: warning: directory '/usr/local/pgsql/lib' following -L not found
    ld: warning: directory '/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib' following -L not found
    ld: warning: directory '/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib' following -F not found

    The same happens when I choose "Build project test" from QtCreator's menu. What I suspect is missing libraries. If the QtSDK have been installed successfully, how is it possible there are missing libs? Can someone help me please? I am quite new to Mac and even more newbie to Qt.

    Thank you

  2. #2
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: I cannot compile project from command line

    If you're using windows then,
    1. Open Qt 4.* for Desktop (MinGW)
    2. cd to your project file
    3. qmake <your-project>.pro
    4. mingw32-make
    It will start the building process.

    If you're using mac then go to:-

    http://stackoverflow.com/questions/5...line-on-mac-os
    Last edited by sonulohani; 28th July 2012 at 12:10.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: I cannot compile project from command line

    Quote Originally Posted by ZikO View Post
    The same happens when I choose "Build project test" from QtCreator's menu. What I suspect is missing libraries. If the QtSDK have been installed successfully, how is it possible there are missing libs? Can someone help me please? I am quite new to Mac and even more newbie to Qt.

    Thank you
    warning says missing directory, not missing lib.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I cannot compile project from command line

    I have installed QtSDK 1.2.1 in windows 7 64bit, as well. I do not really know what I am doing wrong but it is not working producing even more confusing messages in windows :/ First of all, I have PATH set to my own MinGW version 4.7.x whereas QtSDK installed its own version 4.4.x. I can try with MinGW 4.4.x but I think the problem is not there. There are a lot of variations of errors depending on how I compile the project, inside or outside the QtCreator and how I run the resulted exe file!

    In windows
    Neither "Build All" nor "Build the project test" works for first time. Eventually, one of them builds the project. When I build a project in QtCreator, it works only when it is run in QtCreator (Green arrow indicating run program). The build option is set to Debug. However, when I try to run the test.exe inside Debug folder outside of QtCreator by double clicking on it, I've got this message:
    "The procedure entry point ??1 QPushButton@@UAE@XZ could not be located in the dynamic link library QtGui4.dll"

    If I build the project in command line following sonulohani's suggestions, then I cannot run it at all. QtCreator wants to build it again. In command line on the other hand, it does nothing. If I double clicking in a window on .\Debug\test.exe, windows show this message:
    "test.exe has stopped working. Windows is collecting more information about the problem. This might take several minutes..."
    and windows asks to send more information about the problem.

    It is really strange because I did not change anything inside QtCreator I have just install it and wanted to run the simplest possible project with one source file. I have no idea what to do to fix it :/


    @amleto
    Quote Originally Posted by amleto
    warning says missing directory, not missing lib
    How can I fix it? Can you be more elaborative please? I am not an advanced Qt programmer so this does not really help!


    EDIT:
    https://bugreports.qt-project.org/browse/QTBUG-25709
    This is a bug in Qt 4.8.1 -.- I don't know what to workaround it tbh
    Last edited by ZikO; 28th July 2012 at 15:51.

  5. #5
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I cannot compile project from command line

    Recently, I have been trying to deal with these problems. I've also tried this:
    Qt Code:
    1. qmake -o project.dsp project.pro
    To copy to clipboard, switch view to plain text mode 
    but Visual Studio also says there is the problem as the .dsp file is corrupted -.- (obviously, I tried this in windows).

    To be perfectly honest, nothing works about Qt neither in Mac OS X nor in windows! As I said before, I just installed it in default folders (Mac OS X and Windows) and did not change any single option but it still does not work. Does anybody else has any similar problem to mine?

    I would be grateful if anybody could guide me or suggest any place where I could ask hot to solve these issues or to get answers?

    Thanks

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: I cannot compile project from command line

    The bug you have linked to gives you a workaround to get rid of the warning message. The warning message itself is just that, a warning, and should not stop the program from building.

    On the Windows machine: it looks like your runtime environment has Qt libraries built with MSVC rather than MinGW. For an executable built with MinGW you want libraries built with MinGW in the runtime PATH. In the Qt SDK directory these are found in \QtSDK\Desktop\Qt\4.8.1\mingw\bin NOT \QtSDK\QtCreator\bin. There may be issues using MingW 4.4 libs with a 4.7 executable but I cannot say for sure having never tried the unsupported option.

  7. #7
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I cannot compile project from command line

    Hi Chris,

    Thanks for your answer. Do you know if I can sort of set up QtCreator to use proper compiler / debugger etc. so that it will build projects properly? I don't want to use MSVC but MinGW. I have VC++ installed in my machine just for some projects I sometimes need to open.

    Cheers!

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: I cannot compile project from command line

    You set up a fully working Qt environment by installing the Qt SDK for Windows. As long as you install the MingW compiler (under Miscellaneous in the Qt SDK Installer/Maintenance tool) and Qt libraries built with that tool chain (under Development Tools/Desktop Qt/Qt 4.8.x) you get a system that can build Qt applications.

    If you want to use the Microsoft compiler then you need to install the Qt libraries for the particular MSVC version and you do not need MingW.

    On Mac you need to install XCode and some command line tools bundle from the App Store as well as the Qt SDK. I cannot remember the precise details of the command line tools bundle; I've only done it once.
    Last edited by ChrisW67; 31st July 2012 at 00:19.

  9. #9
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: I cannot compile project from command line

    Hello,

    I'd like to thank for the help provided. I understand it was difficult to provide an exact help as each situation and configuration might differ between one another. I think I managed to get Qt worked on both Mac and Windows that I am really happy with.

    Best wishes

Similar Threads

  1. How to compile from command line?
    By tonnot in forum Newbie
    Replies: 6
    Last Post: 15th March 2011, 14:55
  2. Replies: 2
    Last Post: 28th May 2010, 09:16
  3. QProcess and the command line
    By auba in forum Qt Programming
    Replies: 17
    Last Post: 27th May 2009, 10:39
  4. Printing to Command Line
    By seanmu13 in forum Qt Programming
    Replies: 3
    Last Post: 5th July 2007, 15:57
  5. Is there a command-line window in Qt4?
    By miaoliang in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2006, 08:56

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
  •  
Qt is a trademark of The Qt Company.