Advertisement
SRD

makefile

SRD
Jul 29th, 2020 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. I have a Makefile.am setup much like what follows in order to compile MOC files for Qt using Autotools. I think it may have something to do with not finding the headers as they are located outside of the directory which is compiling the cpp files.
  2.  
  3. ---
  4. bin_PROGRAMS = test
  5.  
  6. test_qtheaders = window.h
  7.  
  8. test_moc_sources = $(test_qtheaders:.h=_moc.cpp)
  9.  
  10. test_SOURCES = \
  11. main.cpp \
  12. main-window.cpp \
  13. window.cpp \
  14. $(test_moc_sources)
  15.  
  16. test_CPPFLAGS = -I/usr/include -I/usr/local/include -I$(QT5_INCL) -I$(QT5_INCL)/QtWidgets -I$(QT5_INCL)/QtCore
  17.  
  18. test_LDFLAGS = -L/usr/lib64 -L/usr/local/lib64 -L/usr/local/lib -L$(QT5_LIBS)
  19.  
  20. test_LDADD = -lrt -lQt5Core -lQt5Gui -lQt5Widgets
  21.  
  22. SUFFIXES = .h _moc.cpp
  23.  
  24. # problem here, not able to find where the *.h file is as it's not in the current directory.
  25. .h_moc.cpp:
  26. $(QT_MOC) -o $@ $(test_CPPFLAGS) $(CPPFLAGS) $<
  27. ---
  28. I get the following error.
  29. make[4]: *** No rule to make target 'window_moc.cpp', needed by 'test-window_moc.o'. Stop.
  30.  
  31. My directory structure appears as follows:
  32.  
  33. myproj
  34. |- configure.ac
  35. |- Makefile.am
  36. |- ...
  37. ` src
  38. |- Makefile.am
  39. |- includes
  40. | `- gui
  41. | |- main-window.h
  42. | `- window.h // MOC source file used to generate *.cpp.
  43. |
  44. `- gui
  45. |- Makefile.am
  46. |- main.cpp
  47. |- main-window.cpp
  48. `- window.cpp // MOC file yet to be generated, does not yet exist before build.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement