1

I have an app which uses Gtkmm for UI and I can compile it with a command line (saved in a script), and have read/tried to use a Makefile for it. See below:

SRCDIR = src
BINDIR = bin

OBJECTS = $(SRCDIR)/Dependency_1.o $(SRCDIR)/Dependencies_2.o $(SRCDIR)/Dependencies_N.o $(SRCDIR)/Gtkmm_Definitions.o App_Gtkmm.o

GTKFLAGS = `pkg-config --cflags gtkmm-3.0`
LIBS = `pkg-config --libs gtkmm-3.0`

CXX = g++
CXXFLAGS = -Wall -pthread -mms-bitfields

debug: EXEC = App_Gtkmm_debug
debug: $(OBJECTS)
    $(CXX) $(CXXFLAGS) $(GTKFLAGS) -o $(BINDIR)/$(EXEC) $(OBJECTS) $(LIBS)

clean:
    rm $(SRCDIR)/*.o $(BINDIR)/App_Gtkmm*

There is another target which I omitted for simplicity. The file structure is: Dependencies_X have class definitions which are just standard C++; Gtkmm_Definitions.hpp/.cpp have the Gtkmm-related declarations and definitions (gtkmm.h is included here) and App_Gtkmm.cpp is the main program.

When running "make debug", it will compile just part of the sources in the 1st pass and stop with some errors, that are gone when I run a 2nd time. This already seems a problem. Then it will stop when trying to compile Gtkmm_Definitions, saying it can't find gtkmm.h.

In file included from src/Gtkmm_Definitions.cpp:1:0:
src/Gtkmm_Definitions.hpp:1:10: fatal error: gtkmm.h: No such file or directory
 #include <gtkmm.h>
          ^~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/Gtkmm_Definitions.o] Error 1

However, this command line compiles without any problem:

g++ -Wall -pthread -mms-bitfields src/Dependencies_1.cpp src/Dependencies_N.cpp src/Gtkmm_Definitions.cpp App_Gtkmm.cpp -o bin/App_Gtkmm_debug `
pkg-config --cflags gtkmm-3.0 --libs gtkmm-3.0

Can you guys spot anything wrong in this Makefile? I have already tried a great deal of variables change of order, concatenation and online advices here and there.

JayY
  • 109
  • 10
  • Please have a look at https://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands In particular the `--trace` option. – Captain Giraffe May 07 '18 at 22:42
  • Thanks, Captain. I will have a look and then do a debug session as soon as I come back home. – JayY May 08 '18 at 06:41

0 Answers0