Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Build error while importing a simple project from a makefile
Forum Updated to NodeBB v4.3 + New Features

Build error while importing a simple project from a makefile

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 2 Posters 891 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kevinmeal
    wrote on last edited by
    #1

    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

    aha_1980A 1 Reply Last reply
    0
    • K kevinmeal

      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

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @kevinmeal

      • how does your *.pro file looks now?
      • which error do you get exactly?
      • if you want to generate separate targest, you should probably use qmakes SUBIDR template to create your project structure: https://wiki.qt.io/SUBDIRS_-_handling_dependencies

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      3
      • K Offline
        K Offline
        kevinmeal
        wrote on last edited by
        #3

        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 .

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved