Important: Please read the Qt Code of Conduct -

Build error while importing a simple project from a makefile

  • I've looked up on the forum before posting this question, but couldn't find any hints.

    Here is the structure of the makefile

    BASIC = common/code1.o common/code2.o common/code3.o common/code4.o
    OBJECTS = \
    	main_code_1 \
    all: ${BASIC} $(OBJECTS) values
    ${BASIC}: common/code1.hh common/code3.hh common/code4.hh common/different_code.cpp
    $(OBJECTS): ${BASIC}
    	cd get_values; $(MAKE) $(MFLAGS)
    main_code_2: ${BASIC} additional_code.o
    	rm -f *.o ${BASIC} $(OBJECTS) get_values/get_values
    dist-clean: clean

    The directory tree is the following:

    ├── common
    │   ├── code1.cpp
    │   ├── code1.hh
    │   ├── code2.cpp
    │   ├── code2.hpp
    │   ├── different_code.cpp
    │   ├── code3.cpp
    │   ├── code3.hh
    │   ├── code4.cpp
    │   └── code4.hh
    ├── get_values
    │   ├── datab.cpp
    │   ├── datab.h
    │   └── reader.cpp
    ├── additional_code.cpp
    ├── additional_code.hpp
    ├── main_code_1.cpp
    ├── main_code_2.cpp

    How to specify the sources for each specific targets in the .pro file?
    I tried to put everything in the SOURCES and HEADERS variable but it doesn't work like the make file dependencies.

    Thanks in advance.

  • Lifetime Qt Champion

    Hi @kevinmeal


  • I solved it temporarily by compiling the object files for the subdirectories (using make directly in the shell) then linking them as libraries in the .pro file.
    Then I added main_code.cpp as SOURCES .

Log in to reply