gcc undefined reference with reference paths defined in makefile -


i learning gcc , have undefined reference errors when running make. using makefile did not create, while troubleshooting these undefined reference errors went through each line of makefile understand happening , try fix problem haven't been successful although did learn lot syntax used in makefile.

here undefined reference output when using make:

/usr/bin/arm-none-eabi-gcc -o0 -g -mcpu=cortex-m3 -mthumb  -i/home/np/stmbook -i/home/np/stm32f10x_stdperiph_lib_v3.5.0/libraries/cmsis/cm3/devicesupport/st/stm32f10x -i/home/np/stm32f10x_stdperiph_lib_v3.5.0/libraries/cmsis/cm3/coresupport -i/home/np/stm32f10x_stdperiph_lib_v3.5.0/libraries/stm32f10x_stdperiph_driver/inc -i. -dstm32f10x_md_vl  -duse_stdperiph_driver -duse_full_assert  -i/home/np/stmbook/library/ff9/src -i/home/np/stmbook/library  -t/home/np/stmbook/stm32f100.ld -mthumb -mcpu=cortex-m3   blinklight.c   -o blinklight /usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol reset_handler; defaulting 08000000 /tmp/cczbjmmi.o: in function `main': /home/np/stmbook/blinklight.c:11: undefined reference `rcc_apb2periphclockcmd' /home/np/stmbook/blinklight.c:14: undefined reference `gpio_structinit' /home/np/stmbook/blinklight.c:18: undefined reference `gpio_init' /home/np/stmbook/blinklight.c:21: undefined reference `systemcoreclock' /home/np/stmbook/blinklight.c:21: undefined reference `systemcoreclock' /home/np/stmbook/blinklight.c:30: undefined reference `gpio_writebit' collect2: error: ld returned 1 exit status make: *** [blinklight] error 1 

and here makefile has 2 parts:

part 1:

templateroot = /home/np/stmbook  # compilation flags gdb  cflags  += -o0 -g asflags += -g  # object files  objs=   $(startup) blinklight.o  objs+=  stm32f10x_gpio.o stm32f10x_rcc.o  # include common make file  include $(templateroot)/makefile.common 

part 2 (makefile.common):

# name of executable  elf=$(notdir $(curdir)).elf                      # tool path  toolroot=/usr/bin  # library path      libroot=/home/np/stm32f10x_stdperiph_lib_v3.5.0  # tools        cc=$(toolroot)/arm-none-eabi-gcc ld=$(toolroot)/arm-none-eabi-gcc ar=$(toolroot)/arm-none-eabi-ar as=$(toolroot)/arm-none-eabi-as  # code paths  device=$(libroot)/libraries/cmsis/cm3/devicesupport/st/stm32f10x core=$(libroot)/libraries/cmsis/cm3/coresupport periph=$(libroot)/libraries/stm32f10x_stdperiph_driver  # search path standard files  vpath %.c $(templateroot)  # search path perpheral library  vpath %.c $(core) vpath %.c $(periph)/src vpath %.c $(device)  # search path library  vpath %.c $(templateroot)/library/ff9/src vpath %.c $(templateroot)/library/ff9/src/option vpath %.c $(templateroot)/library  #  processor specific  ptype = stm32f10x_md_vl  ldscript = $(templateroot)/stm32f100.ld startup= startup_stm32f10x.o system_stm32f10x.o   # compilation flags  fullassert = -duse_full_assert   ldflags+= -t$(ldscript) -mthumb -mcpu=cortex-m3  cflags+= -mcpu=cortex-m3 -mthumb  cflags+= -i$(templateroot) -i$(device) -i$(core) -i$(periph)/inc -i. cflags+= -d$(ptype) -duse_stdperiph_driver $(fullassert) cflags+= -i$(templateroot)/library/ff9/src -i$(templateroot)/library  # build executable   $(elf) : $(objs)     $(ld) $(ldflags) -o $@ $(objs) $(ldlibs)  # compile , generate dependency info  %.o: %.c     $(cc) -c $(cflags) $< -o $@     $(cc) -mm $(cflags) $< > $*.d  %.o: %.s     $(cc) -c $(cflags) $< -o $@  clean:     rm -f $(objs) $(objs:.o=.d) $(elf) startup_stm32f* $(cleanother)  debug: $(elf)     arm-none-eabi-gdb $(elf)   # pull in dependencies      -include $(objs:.o=.d) 

here understanding:

the undefined references contained in files stm32f10x_gpio.c (gpio undefined references) , stm32f10x_rcc.c (rcc undefined reference) , these declared required objects in objs variable in part 1 of makefile:

objs=   $(startup) blinklight.o  objs+=  stm32f10x_gpio.o stm32f10x_rcc.o 

undefined reference 'systemcoreclock' located in system_stm32f10x.c file in directory given in makefile as:

startup= startup_stm32f10x.o system_stm32f10x.o 

and included in objs variable.

the path .c files compiling required objects defined in makefile:

location of stm32f10x_gpio.c , stm32f10x_rcc.c:

vpath %.c $(periph)/src 

location of system_stm32f10x.c:

vpath %.c $(device) 

all of required objects contain undefined references passed target build instructions variable objs:

$(elf) : $(objs)     $(ld) $(ldflags) -o $@ $(objs) $(ldlibs) 

also included in makefile build instructions on how obtain object files c source files:

%.o: %.c     $(cc) -c $(cflags) $< -o $@     $(cc) -mm $(cflags) $< > $*.d 

i not understand why seems c source files cannot found. thank suggestions, appreciate help.

sorry post being long, tried go through each line of makefile , research symbols , syntax figure out problem on own , went through many of undefined reference questions on site have not figured out.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -