3

I am quite new to both writing a makefiles and Objective-C language. I am trying to compile a small test application with this Makefile:

Q = @
INCLUDE_PREF = -I

CC := gcc 

#Here the source files are specified

list_src_files = $(shell find . -type f -name "*.m")
SRCS := $(subst ./,,$(call list_src_files))

#Here is our include files

list_include_dirs = $(shell find . -type d -name "include")
INCLUDE_LS := $(call list_include_dirs)
INCLUDE_DIRS := $(INCLUDE_PREF).
INCLUDE_DIRS += $(addprefix $(INCLUDE_PREF), $(subst ./,,$(INCLUDE_LS)))

#Flags used with gcc

CFLAGS = -Wall -fobjc-arc -framework Foundation -g -O0 $(INCLUDE_DIRS)

#Here all object files are specified

OBJS := $(SRCS:%.m=%.o)

#Here is the name of target specified

TARGET := Convertor

#Here is our target

$(TARGET): $(OBJS)
           @echo "Building target"
           $(Q)$(CC) $(CFLAGS) $^ -o $@

%.o: %.m 
     @echo "Building objects"
     $(Q)$(CC) $(CFLAGS) -c $< -o $@

.PHONY: clean

clean:
      $(Q)-rm $(OBJS) $(TARGET) 2>/dev/null || true

The code I am trying to compile is:

#import <Foundation/Foundation.h>


#define DEBUG
#define VALID_PARMS_NBR   3   

#ifdef DEBUG
# define dbg(fmt, ...) NSLog((@"%s " fmt), __PRETTY_FUNCTION__,  ##__VA_ARGS__)
#else
# define dbg(...)
#endif



int main (int argc, char *argv[])
{
  if (argc < VALID_PARMS_NBR) {
    NSLog(@"Usage of this program is: prog_name arg1 arg2");
  } else {
    dbg(@"Parameters: %s, %s, %s\n", argv[0], argv[1], argv[2]);
  }


  return 0;
}

The warning compiler is throwing me everytime:

clang: warning: -framework Foundation: 'linker' input unused

Could you, please, point me, where I did mistake in a Makefile? And why this warning appears?

I was looking through the similar questions, but nothing worked.

1 Answer 1

2

The warning indicates the Foundation framework statement isn't used, and can be removed:

CFLAGS = -Wall -fobjc-arc -g -O0 $(INCLUDE_DIRS)

Removing it from the CFLAGS line should resolve things.

Warnings are just that — to warn you about behavior that might not necessarily be a problem, but something to be aware of. Despite this the program might compile anyway, although it's good that you have the mindset to fix it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.