Results 1 to 3 of 3

Thread: makefile without using QMake

  1. #1
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default makefile without using QMake

    I am developing a multi-language application (c, c++, FORTRAN and soon Java...hopefully), and used qmake only once to create the makefile. Since then, I have been just updating the makefile each time by hand. I am trying to get the makefile to be able to handle generic filename redirections i.e (this is an example from the net, not my actual makefile...):

    Qt Code:
    1. CXX=g++
    2. CC=gcc
    3. FC=pgf77
    4. CFLAGS=-c -Wall
    5. FFLAGS=
    6. LDFLAGS=
    7. SOURCES=main.cpp hello.cpp factorial.f
    8. OBJECTS=$(SOURCES:.cpp=.o)
    9. EXECUTABLE=hello
    10.  
    11. :
    12. :
    13.  
    14. all: $(SOURCES) $(EXECUTABLE)
    15.  
    16. $(EXECUTABLE): $(OBJECTS)
    17. $(CC) $(LDFLAGS) $(OBJECTS) -o $@
    18.  
    19. .cpp.o:
    20. $(CXX) $(CXXFLAGS) $< -o $@
    21.  
    22. .c.o:
    23. $(CC) $(CFLAGS) $< -o $@
    24.  
    25. .f.o:
    26. $(FC) $(FFLAGS) $< -o $@
    27.  
    28. #Steps for moc...
    29. ???
    To copy to clipboard, switch view to plain text mode 
    and moc the correct Q_OBJECT files at the same time. I have created a variable call MOC_FILES that lists all the files to be moc'd but each time I try and create a generic moc rule, nothing compiles. I am "so-so" at makefiles, and was wondering if anyone has sucessfully done this? Also, I am not using UI files or Project (.pro) files in Qt. I am writing all code by hand.

  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

  3. The following user says thank you to jacek for this useful post:

    Rayven (8th September 2006)

  4. #3
    Join Date
    Apr 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: makefile without using QMake

    Here is an example of modified `makefile` based on the `Makefile` generated by Qmake under Qt/4.6.2/examples/opengl/textures.

    Qt Code:
    1. prog = f90main
    2.  
    3. F90 = gfortran
    4. F90FLAGS = -m32 -O1 -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_NEEDS_QMAIN
    15. CFLAGS = -m32 -O2 -Wall $(DEFINES)
    16. CXXFLAGS = -m32 -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES)
    17. 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/include' \
    18. -I'c:/minGW/Qt/4.6.2/include/ActiveQt' -I'tmp/moc/release_shared' -I'c:/minGW/Qt/4.6.2/mkspecs/win32-g++'
    19.  
    20. LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows
    21. LIBS = -L'c:/minGW/Qt/4.6.2/lib' -L'c:/minGW/Qt/4.6.2/lib' -lstdc++ -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQtOpenGL4 -lQtGui4 -lQtCore4
    22.  
    23. ####### Files
    24. SOURCES = qtmain.cpp glwidget.cpp window.cpp moc_glwidget.cpp moc_window.cpp
    25. OBJECTS = qtmain.o glwidget.o window.o moc_glwidget.o moc_window.o qrc_textures.o
    26. TARGET = $(prog).exe
    27.  
    28. MOC = $(Qt)/bin/moc
    29.  
    30. ####### Implicit rules
    31. .SUFFIXES: .o .c .cpp .cc .cxx .C .f .h
    32.  
    33. .f.o:
    34. $(F90) -c $(F90FLAGS) $(F90INCPATH) -o $@ $<
    35.  
    36. .cpp.o:
    37. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
    38.  
    39. .cc.o:
    40. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
    41.  
    42. .cxx.o:
    43. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
    44.  
    45. .C.o:
    46. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
    47. .c.o:
    48. $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
    49.  
    50.  
    51. ####### Build rules
    52. $(TARGET): $(f90Objects) $(OBJECTS)
    53. $(LINK) $(LFLAGS) -o $(TARGET) $(f90Objects) $(OBJECTS) $(LIBS)
    54.  
    55. ####### moc
    56. moc_glwidget.cpp: glwidget.h
    57. $(MOC) $(DEFINES) $(INCPATH) glwidget.h -o moc_glwidget.cpp
    58.  
    59. moc_window.cpp: window.h
    60. $(MOC) $(DEFINES) $(INCPATH) window.h -o moc_window.cpp
    61.  
    62. ####### rcc
    63. RCC = $(Qt)/bin/rcc
    64. qrc_textures.cpp: textures.qrc images/side4.png images/side5.png images/side6.png images/side1.png images/side2.png images/side3.png
    65. $(RCC) -name textures textures.qrc -o qrc_textures.cpp
    66.  
    67. moc_glwidget.o: moc_glwidget.cpp window.h
    68. moc_window.o: moc_window.cpp window.h
    69.  
    70. all: $(TARGET)
    71.  
    72. clean:
    73. rm *.o
    74. rm moc*.cpp
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Flex, Bison and qmake
    By Hydragyrum in forum Qt Programming
    Replies: 5
    Last Post: 2nd May 2011, 15:52
  2. Replies: 5
    Last Post: 13th March 2006, 20:22
  3. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01:48
  4. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11
  5. Replies: 1
    Last Post: 11th January 2006, 14:15

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.