collet2 (gate.c:(.text+0x65): undefined reference to `function') 함수 링크 오류
글쓴이: unuseid / 작성시간: 화, 2016/11/01 - 2:19오후
기존 프로젝트에 새 c,h 파일을 추가 했는데 링크 단계에서 오류가 납니다
어디가 잘못된 걸까요?
gate.o: In function 'gate_funtion': gate.c : (.text+0x45): undefined reference to 'regi_start' collect2: error: ld returned 1 exit status
새로추가한 gate.c 는 함수내에서기존에 있는 파일인 regi.c에 있는 함수를 사용합니다.
regi.c의 함수의 선언은 다른 c파일들의 함수선언들과 함께 internals.h에 있습니다
main.c는 gate.h와 internals.h를 include 했습니다.
internal에 선언 돼 있는 다른 c파일(regi.c 포함)의 함수들은 main에서 잘 작동 합니다.
gate.c는 internals.h에 선언된 상수는 이상없이 함수를 통해 출력 할 수 있습니다.
아래는 Makefile 과 폴더의 구조입니다
CC = gcc -g -ggdb LD = gcc -g -ggdb #CC = arm-none-linux-gnueabi-gcc #LD = arm-none-linux-gnueabi-gcc SRCDIR1 = core SRCDIR2 = core/A SRCDIR3 = examples/A SRCDIR4 = examples/B SRCDIR5 = examples/C VPATH = $(SRCDIR1) $(SRCDIR2) $(SRCDIR3) $(SRCDIR4) $(SRCDIR5) #CFLAGS = -O2 -I$(SRCDIR1) -I$(SRCDIR2) -I$(SRCDIR3) -I$(SRCDIR4) -DLWM2M_LITTLE_ENDIAN -DLWM2M_WITH_LOGS -DLWM2M_SERVER_MODE -DDEBUG CFLAGS = -O2 -I$(SRCDIR1) -I$(SRCDIR2) -I$(SRCDIR3) -I$(SRCDIR4) -I$(SRCDIR5) -DLWM2M_LITTLE_ENDIAN -DLWM2M_WITH_LOGS -DLWM2M_CLIENT_MODE -DLWM2M_BOOTSTRAP -std=gnu99 -lpthread LDFLAGS = -lpthread TARGET = lwm2mclient SRCS = $(foreach dir, .. $(SRCDIR1) $(SRCDIR2) $(SRCDIR3) $(SRCDIR4) $(SRCDIR5), $(wildcard $(dir)/*.c)) SRCS := $(notdir $(SRCS)) OBJS = $(SRCS:.c=.o) all: $(TARGET) $(TARGET): $(OBJS) $(LD) $^ -lm -o $(TARGET) %o:%c $(CC) $(CFLAGS) -c $< -o $@ clean: -rm -f $(OBJS) -rm -f $(TARGET) depend: $(SRCS) $(CC) -M $(CFLAGS) $^ > $@ -include depend
File attachments:
첨부 | 파일 크기 |
---|---|
![]() | 12.71 KB |
Forums:
댓글 달기