public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Building library with extern data fails in GCC
@ 2012-08-31 19:24 HvW
  2012-09-02 22:50 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: HvW @ 2012-08-31 19:24 UTC (permalink / raw)
  To: gcc-help

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. 

http://gcc.1065356.n5.nabble.com/file/n865274/code_makefile.rar
code_makefile.rar 

Please help me solve this problem.

Thanks,




--
View this message in context: http://gcc.1065356.n5.nabble.com/Building-library-with-extern-data-fails-in-GCC-tp865274.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Building library with extern data fails in GCC
  2012-08-31 19:24 Building library with extern data fails in GCC HvW
@ 2012-09-02 22:50 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2012-09-02 22:50 UTC (permalink / raw)
  To: HvW; +Cc: gcc-help

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-02 22:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-31 19:24 Building library with extern data fails in GCC HvW
2012-09-02 22:50 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).