gfortran works perfectly with Qt under Fedora12. But it does not work properly with minGW/Msys under windows XP.

Here is the modified example from qt/examples/opengl/grabber

f90main.f
Qt Code:
  1. program f90main
  2. !-------------------------------------------------------
  3. ! Apr-05-2010 V1.0.0 Apr-05-2004 File: f90main.f
  4. !-------------------------------------------------------
  5.  
  6. implicit none
  7.  
  8. integer (2) :: i,iargc
  9. integer (4) :: Narg
  10. character (80) :: Farg(5)
  11.  
  12. !---get fortran command-line arguments
  13. Narg = iargc()
  14. do i=1,Narg
  15. call getarg (i,Farg(i))
  16. end do
  17.  
  18. call Qtmain (Narg,Farg)
  19.  
  20. END program f90main
To copy to clipboard, switch view to plain text mode 

qtmain.cpp
Qt Code:
  1. /******************************************************
  2.   Apr-05-2010 V1.0.0 Apr-05-2010 File: qtmain.cpp
  3. ******************************************************/
  4.  
  5. #include <QApplication>
  6.  
  7. #include "mainwindow.h"
  8.  
  9. extern "C" {
  10.  
  11. MainWindow *qt ;
  12.  
  13. void qtmain_ (int *argc, char *argv[]) {
  14.  
  15. QApplication app(*argc, argv);
  16. MainWindow mainWin;
  17. qt = &mainWin;
  18. mainWin.show();
  19. app.exec();
  20. }
  21. }
To copy to clipboard, switch view to plain text mode 

makefile for minGW/Msys under windows XP
Qt Code:
  1. prog = f90main
  2.  
  3. F90 = gfortran
  4. F90FLAGS = -m32 -O2 -ffree-line-length-0 -ffree-form
  5.  
  6. LINK = gfortran
  7.  
  8. f90Objects = f90main.o
  9.  
  10. Qt = /mingw/Qt/4.6.2
  11.  
  12. CC = gcc
  13. CXX = g++
  14. DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_EVAL -DQT_DLL -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_
  15. NEEDS_QMAIN
  16. CFLAGS = -m32 -O2 -Wall $(DEFINES)
  17. CXXFLAGS = -m32 -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES)
  18. INCPATH = -I'c:/minGW/Qt/4.6.2/include/QtCore' -I'c:/minGW/Qt/4.6.2/include/QtGui' -I'c:/minGW/Qt/4.6.2/include/QtOpenGL' -I'c:/minGW/Qt/4.6.2/i
  19. nclude' \
  20. -I'c:/minGW/Qt/4.6.2/include/ActiveQt' -I'tmp/moc/release_shared' -I'c:/minGW/Qt/4.6.2/mkspecs/win32-g++'
  21.  
  22. LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows
  23. LIBS = -L'c:/minGW/Qt/4.6.2/lib' -lstdc++ -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQtOpenGL4 -lQtGui4 -lQtCore4
  24.  
  25. ####### Files
  26. SOURCES = qtmain.cpp glwidget.cpp mainwindow.cpp moc_glwidget.cpp moc_mainwindow.cpp
  27. OBJECTS = qtmain.o glwidget.o mainwindow.o moc_glwidget.o moc_mainwindow.o
  28. TARGET = $(prog).exe
  29.  
  30. MOC = $(Qt)/bin/moc
  31.  
  32. ####### Implicit rules
  33. .SUFFIXES: .o .c .cpp .cc .cxx .C .f .h
  34.  
  35. .f.o:
  36. $(F90) -c $(F90FLAGS) $(F90INCPATH) -o $@ $<
  37.  
  38. .cpp.o:
  39. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
  40.  
  41. .cc.o:
  42. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
  43.  
  44. .cxx.o:
  45. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
  46.  
  47. .C.o:
  48. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
  49.  
  50. .c.o:
  51. $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
  52.  
  53.  
  54. ####### Build rules
  55. $(TARGET): $(f90Objects) $(OBJECTS)
  56. $(LINK) $(LFLAGS) -o $(TARGET) $(f90Objects) $(OBJECTS) $(LIBS)
  57.  
  58. ####### moc
  59. moc_glwidget.cpp: glwidget.h
  60. $(MOC) $(DEFINES) $(INCPATH) glwidget.h -o moc_glwidget.cpp
  61.  
  62. moc_mainwindow.cpp: mainwindow.h
  63. $(MOC) $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp
  64.  
  65. moc_glwidget.o: moc_glwidget.cpp mainwindow.h
  66. moc_window.o: moc_window.cpp mainwindow.h
  67.  
  68. all: $(TARGET)
  69.  
  70. clean:
  71. rm *.o
  72. rm moc*.cpp
To copy to clipboard, switch view to plain text mode 

For GNU Fortran (GCC) 4.4.3 under fedora12 with Qt 4.6.2, it works fine. But with GNU Fortran (GCC) 4.4.0 and GNU make 3.81 with Qt 4.6.2 under minGW/Msys/windows XP, it gave the errors:

Qt Code:
  1. c:/minGW/Qt/4.6.2/lib/libqtmain.a(qtmain_win.o):qtmain_win.cpp:(.text+0x131): undefined reference to `qMain(int, char**)'
  2. collect2: ld returned 1 exit status
  3. make: *** [f90main.exe] Error 1
To copy to clipboard, switch view to plain text mode 

Is there a walk-around solution for this problem?
Thanks