2015-08-25 29 views
2

我對編寫makefile和Objective-C語言都很陌生。我試圖編譯這個Makefile一個小的測試應用程序:在Mac OS的終端上編譯Objective-C

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 [email protected] 

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

.PHONY: clean 

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

我試圖編譯的代碼是:

#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; 
} 

警告編譯器扔我每次:

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

請問,請指出我在哪裏弄錯了Makefile?爲什麼會出現此警告?

我正在查看類似的問題,但沒有任何工作。

回答

2

的警告表明不使用Foundation框架語句,可以將其刪除:

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

CFLAGS行刪除它應該解決的事情。

警告只是 - 警告你可能不一定是問題的行爲,但要注意一些事情。儘管如此,該程序仍然可以進行編譯,儘管您有修理它的想法是件好事。