On Aug 31, 2012 2:51 PM, "HvW" wrote: > > Hi, > > I am trying to create a library that handles the USART TX and RX data. The > buffer used for the TX and RX data I declared as extern as this needs to be > specified by the application using the library. This works fine in Keil > ARM-MDK. Attempting to build this in the latest version of GCC shows the > following errors: > > C:\yagarto_cortex_m3\bin\arm-none-eabi-gcc libhl_usart.o -mcpu=cortex-m3 > -mthumb -nostartfiles -Tstm32f103x_xl_flash.ld > -Wl,-Map=lib_usart.map,--cref,--no-warn-mismatch -L./lib/ -lm -lgcc -lc > ./lib/lib_stm3210x_xl_stdperiph.a -o lib_usart.elf > libhl_usart.o: In function `Libhl_Usart_Lib_Init': > libhl_usart.c:(.text+0x1a): undefined reference to `Libhl_Usart2_Tx_Buff' > libhl_usart.c:(.text+0x1e): undefined reference to `Libhl_Usart2_Tx_Buff' > libhl_usart.c:(.text+0x2c): undefined reference to `Libhl_Usart3_Tx_Buff' > libhl_usart.c:(.text+0x30): undefined reference to `Libhl_Usart3_Tx_Buff' > libhl_usart.c:(.text+0x3e): undefined reference to `Libhl_Uart4_Tx_Buff' > libhl_usart.c:(.text+0x42): undefined reference to `Libhl_Uart4_Tx_Buff' > libhl_usart.c:(.text+0x50): undefined reference to `Libhl_Uart5_Tx_Buff' > libhl_usart.c:(.text+0x54): undefined reference to `Libhl_Uart5_Tx_Buff' > libhl_usart.c:(.text+0x62): undefined reference to `Libhl_Usart1_Rx_Buff' > libhl_usart.c:(.text+0x66): undefined reference to > > > I am sure that I am just missing some compiler option that will allow it to > assume that the data will be available when needed. > > I am attaching the code and makefile. I haven't looked at the code or makefile, but the command above doesn't tell gcc to build a library, it builds a final executable, or tries to. To create a shared library use the gcc option -shared, or to create a static library use ar instead of gcc.