It looks like it is not working,
myprojectdir\>qmake -o Makefile myproject.pro
D:\Proyectos\myproject\Levedit>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/Proyectos/myproject/Levedit'
g++ -c -O2 -Wall -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT
_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\
iwmake\build_mingw_opensource\include\QtCore" -I"c:\iwmake\build_mingw_opensourc
e\include\QtGui" -I"c:\iwmake\build_mingw_opensource\include" -I"." -I"c:\iwmake
\build_mingw_opensource\include\ActiveQt" -I"release" -I"." -I"..\..\Libraries\C
PP\Mingw\Qt\4.4.2\mkspecs\win32-g++" -o release\main.o main.cpp
main.cpp:1:24: QApplication: No such file or directory
In file included from main.cpp:2:
mainwindow.h:4:23: QMainWindow: No such file or directory
In file included from main.cpp:2:
mainwindow.h:20: error: expected class-name before '{' token
mainwindow.h:23: error: ISO C++ forbids declaration of `Q_OBJECT' with no type
mainwindow.h:23: error: expected `;' before "public"
mainwindow.h:27: error: `QCloseEvent' has not been declared
mainwindow.h:27: error: ISO C++ forbids declaration of `event' with no type
mainwindow.h:29: error: expected `:' before "slots"
mainwindow.h:30: error: expected primary-expression before "void"
mainwindow.h:30: error: ISO C++ forbids declaration of `slots' with no type
mainwindow.h:30: error: expected `;' before "void"
mainwindow.h:42: error: `QWidget' has not been declared
mainwindow.h:42: error: ISO C++ forbids declaration of `window' with no type
mainwindow.h:52: error: expected `,' or `...' before '&' token
mainwindow.h:52: error: ISO C++ forbids declaration of `QString' with no type
mainwindow.h:61: error: ISO C++ forbids declaration of `QToolBar' with no type
mainwindow.h:61: error: expected `;' before '*' token
mainwindow.h:62: error: ISO C++ forbids declaration of `QToolBar' with no type
mainwindow.h:62: error: expected `;' before '*' token
main.cpp: In function `int main(int, char**)':
main.cpp:6: error: `mdi' was not declared in this scope
main.cpp:6: error: `Q_INIT_RESOURCE' was not declared in this scope
main.cpp:8: error: `QApplication' was not declared in this scope
main.cpp:8: error: expected `;' before "app"
main.cpp:10: error: 'class mainWindow' has no member named 'show'
main.cpp:11: error: `app' was not declared in this scope
main.cpp:6: warning: unused variable 'mdi'
main.cpp:6: warning: unused variable 'Q_INIT_RESOURCE'
main.cpp:8: warning: unused variable 'QApplication'
main.cpp:11: warning: unused variable 'app'
mingw32-make[1]: *** [release/main.o] Error 1
mingw32-make[1]: Leaving directory `D:/Proyectos/myproject/Levedit'
mingw32-make: *** [release] Error 2
So I tried this:
D:\Proyectos\myproject\Levedit>qmake -project
D:\Proyectos\myproject\Levedit>qmake -makefile
This way qmake generates the pro file automatically. Then type:
D:\Proyectos\myproject\Levedit>mingw32-make
Exactly the same error outputs. But this time, in the console, I see new outputs, pay attention to:
"c:\iwmake\build_mingw_opensource\include\QtCore" -I"c:\iwmake\build_mingw_opensourc
e\include\QtGui"
This dir appears many times, It seems that the makefile generated by qmake is pointing to a directory that is not my qt directory. But I have set the environment variables correctly: QTDIR = D:\Proyectos\Libraries\CPP\Mingw\Qt\4.4.2. No problem when compiling in Code Blocks without custom makefile because my Code Blocks global variables are correctly configured, so this works for simple qt samples. But, when using a custom make file, the ide global variables aren't used. In theory, as I also have my system environment var, QTDIR, correctly, this must work too, but for some reason this doesn't enough. The qmake made makefile is pointing to "c:\iwmake\..." and not to my QTDIR directory.
Ok, at least now I know that the problem is not in my CB project configuration. It is in my QT configuration. Anyway, any ideas how to solve it?
Thanks for read, JH
Edited September 28:
My mistake, one of two problems solved. I configured QTDIR in environment variables but I didn't add qt bin directory to path variable. Now I can build with mingw32-make outside Code::Blocks. Now, let see if I can do it using Code::Blocks. Also, there is an undefined reference error, the linker says "release\main.o:main.cpp:(.text+0x56)||undefined reference to `qInitResources_mdi()'|". But, I think this is not due to Code::Blocks configuration but something wrong in my code.
Edited again:
Another mistake, I forgot to change the resource file name in my code to the actual resource file name in my project directory. Now I able to compile correctly from command line using mingw32-make, the exe appears in my release directory and until now it works as expected. But every time I try to compile in Code::Blocks the following output is returned:
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/Proyectos/Hellsing Fan Game/Levedit'
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtCore" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtCore" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtGui" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtGui" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include" -I"." -I"d:\Proyectos\Libraries\CPP\Mingw\Qt\4.4.2\include\ActiveQt" -I"release" -I"." -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\mkspecs\win32-g++" -o release\mainwindow.o mainwindow.cpp
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtCore" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtCore" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtGui" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include\QtGui" -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\include" -I"." -I"d:\Proyectos\Libraries\CPP\Mingw\Qt\4.4.2\include\ActiveQt" -I"release" -I"." -I"..\..\Libraries\CPP\Mingw\Qt\4.4.2\mkspecs\win32-g++" -o release\mdichild.o mdichild.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\Levedit.exe release/main.o release/mainwindow.o release/mdichild.o release/moc_mainwindow.o release/moc_mdichild.o release/qrc_levedit.o -L"d:\Proyectos\Libraries\CPP\Mingw\Qt\4.4.2\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
release/moc_mainwindow.o:moc_mainwindow.cpp:(.text+0x0): multiple definition of `mainWindow::metaObject() const'
mingw32-make[1]: Leaving directory `D:/Proyectos/Hellsing Fan Game/Levedit'
release/mainwindow.o:mainwindow.cpp:(.text+0x3550): first defined here
release/moc_mainwindow.o:moc_mainwindow.cpp:(.text+0x10): multiple definition of `mainWindow::qt_metacast(char const*)'
release/mainwindow.o:mainwindow.cpp:(.text+0x3560): first defined here
release/moc_mainwindow.o:moc_mainwindow.cpp:(.text+0x60): multiple definition of `mainWindow::qt_metacall(QMetaObject::Call, int, void**)'
release/mainwindow.o:mainwindow.cpp:(.text+0x5780): first defined here
release/moc_mainwindow.o:moc_mainwindow.cpp:(.data+0x0): multiple definition of `mainWindow::staticMetaObject'
release/mainwindow.o:mainwindow.cpp:(.data+0x0): first defined here
release/moc_mdichild.o:moc_mdichild.cpp:(.text+0x0): multiple definition of `MdiChild::metaObject() const'
release/mdichild.o:mdichild.cpp:(.text+0xad0): first defined here
release/moc_mdichild.o:moc_mdichild.cpp:(.text+0x10): multiple definition of `MdiChild::qt_metacast(char const*)'
release/mdichild.o:mdichild.cpp:(.text+0xae0): first defined here
release/moc_mdichild.o:moc_mdichild.cpp:(.text+0x60): multiple definition of `MdiChild::qt_metacall(QMetaObject::Call, int, void**)'
release/mdichild.o:mdichild.cpp:(.text+0xb30): first defined here
release/moc_mdichild.o:moc_mdichild.cpp:(.data+0x0): multiple definition of `MdiChild::staticMetaObject'
release/mdichild.o:mdichild.cpp:(.data+0x0): first defined here
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\Levedit.exe] Error 1
mingw32-make: *** [Release] Error 2
Process terminated with status 2 (0 minutes, 19 seconds)
0 errors, 0 warnings
Again, what are the correctly CB settings to successfully compile using a qmake generated makefile?
Thanks for read, JH