PDA

View Full Version : I cannot compile project from command line



ZikO
28th July 2012, 12:35
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:

#include <QtGui>

int main(int argc, char* argv[]) {
QApplication app(argc, argv);
QPushButton* button = new QPushButton("Hello_word");
button->show();
return app.exec();
}


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:

qmake
make

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

sonulohani
28th July 2012, 12:57
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/5280952/how-to-compile-qt-code-in-command-line-on-mac-os

amleto
28th July 2012, 14:16
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.

ZikO
28th July 2012, 15:23
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

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

ZikO
28th July 2012, 20:54
Recently, I have been trying to deal with these problems. I've also tried this:

qmake -o project.dsp project.pro
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

ChrisW67
30th July 2012, 01:26
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.

ZikO
30th July 2012, 13:56
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!

ChrisW67
31st July 2012, 01:13
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.

ZikO
31st July 2012, 14:50
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