Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:37:50+00:00 2026-06-02T04:37:50+00:00

Help me with makefile, please. I want `make’ to recompile only files that have

  • 0

Help me with makefile, please. I want `make’ to recompile only files that have been changed. Here is my makefile:

ROOT_DIR= ..
BUILD_TYPE= Release
BUILD_DIR= $(ROOT_DIR)/$(BUILD_TYPE)
O_DIR= $(BUILD_DIR)/obj

TARGETS= ftp_auto_backup sftp_auto_backup

CXX= g++
CXXFLAGS= -DBOOST_THREAD_USE_LIB -O3 -Wall -fmessage-length=0
FTP_LDFLAGS= -static-libstdc++ -static-libgcc -s -L $(ROOT_DIR)/lib/Release -l:libboost_thread-mgw46-mt-1_49.a -l:libcommon.a \
    -l:libfile.a -l:libfilesearcher.a -l:libftpclient.a -l:libftplib.a -l:libdbclient.a -l:libsqlite3.a -l:libscheduler.a -l:libws2_32.a
SFTP_LDFLAGS= -static-libstdc++ -static-libgcc -s -L $(ROOT_DIR)/lib/Release -l:libboost_thread-mgw46-mt-1_49.a -l:libcommon.a \
    -l:libfile.a -l:libfilesearcher.a -l:libdbclient.a -l:libsqlite3.a -l:libscheduler.a -l:libsftpclient.a -l:libws2_32.a -l:libssh.dll

OBJECTS= appconfig.o backuplauncher.o clientbackup.o main.o
LD_OBJECTS= $(addprefix $(O_DIR)/,$(OBJECTS))

all: init $(TARGETS)

debug: CXXFLAGS= -O0 -g3 -Wall -fmessage-length=0
debug: BUILD_TYPE= Debug
debug: all

init:
    @mkdir -p $(BUILD_DIR)
    @mkdir -p $(O_DIR)

ftp_auto_backup: set_type_ftp $(OBJECTS) 
    $(CXX) -o $(BUILD_DIR)/$@.exe $(LD_OBJECTS) $(FTP_LDFLAGS)

sftp_auto_backup: set_type_sftp $(OBJECTS)
    $(CXX) -o $(BUILD_DIR)/$@.exe $(LD_OBJECTS) $(SFTP_LDFLAGS)

set_type_ftp:
    $(eval CXXFLAGS+=-DPROJECT_TYPE=FTP)

set_type_sftp:
    $(eval CXXFLAGS+=-DPROJECT_TYPE=SFTP)

%.o: %.cpp
    $(CXX) -c $(CXXFLAGS) $< -o $(O_DIR)/$@

clean:
    rm -rf $(addprefix $(ROOT_DIR)/Release/obj/,$(OBJECTS)) $(addprefix $(ROOT_DIR)/Debug/obj/,$(OBJECTS))
    rm -rf $(addprefix $(ROOT_DIR)/Release/,$(addsuffix .exe,$(TARGETS))) $(addprefix $(ROOT_DIR)/Debug/,$(addsuffix .exe,$(TARGETS)))

Yes, I know about Generating Prerequisites Automatically, but should I really use it?
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:37:52+00:00Added an answer on June 2, 2026 at 4:37 am

    Your targets depend on objects in the current directory, not in obj/. Change to this:

    ftp_auto_backup: set_type_ftp $(LD_OBJECTS)
        $(CXX) -o $(BUILD_DIR)/$@.exe $(LD_OBJECTS) $(FTP_LDFLAGS)
    
    sftp_auto_backup: set_type_sftp $(LD_OBJECTS)
        $(CXX) -o $(BUILD_DIR)/$@.exe $(LD_OBJECTS) $(SFTP_LDFLAGS)
    
    # (...)
    
    $(O_DIR)/%.o: %.cpp
        $(CXX) -c $(CXXFLAGS) $< -o $@
    

    And yes, if you want your object files to recompile not only when you change the .cpp file, but also when you change the header (.h) files, you need to generate those prerequisites…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a exe that will create a triangle strip. I have
I have a multifile c++ project, built with help of Makefile. CC and CXX
I have the following start on a makefile rule (thanks to help from others),
I was writing a makefile and suppose I have the following; FILES = file1.py
I need help with comparing two files in makefile. I need something like this:
i have a small java project i want to build using a makefile, the
In a makefile, I have the following line: helper.cpp: dtds.h Which ensures that helper.cpp
I'm working on using a Makefile to help perform build steps for my JS
Help please on how to extract data like 15,Teaching Periods 1 and 2.,Max 150.
help out a noob with a simple web development question?? I want to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.