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 \
    	main_code_2
    
    
    all: ${BASIC} $(OBJECTS) values
    
    ${BASIC}: common/code1.hh common/code3.hh common/code4.hh common/different_code.cpp
    
    $(OBJECTS): ${BASIC}
    
    values:
    	cd get_values; $(MAKE) $(MFLAGS)
    
    main_code_2: ${BASIC} additional_code.o
    
    clean: 
    	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.
    K


  • Qt Champions 2017

    Hi @kevinmeal

    Regards



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.