undefined reference to `_….'

Sysprogs forums Forums VisualGDB undefined reference to `_….'

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #29520
    c3049518
    Participant

    I am making an embedded STM32CubeMX project with the STM32CubeMX wizard. Since moving my project to a directory with no spaces my previous issue has been resolved. However I have a problem when building the project. There were a few build errors with the code which I have resolved, but I am stuck on the below build errors. Each one throws a undefined reference to `_….’ error. The missing references are _sbrk, _write, _close, _fstat, _isatty, _lseek, _read. I ran the VisualGDB ‘resolve build errors’ tool and it suggested to add a reference to the ‘nosys’ library. This was done, but when I try to build the program now I still get the errors shown in the image attached

    cmd.exe /C “cd . && C:\PROGRA~2\GNUTOO~1\72018-~1\bin\AR19DD~1.EXE -g3 -O0 CMakeFiles/BSP.dir/Src/usb_otg.c.obj CMakeFiles/BSP.dir/Src/usart.c.obj CMakeFiles/BSP.dir/Src/tim.c.obj CMakeFiles/BSP.dir/Src/spi.c.obj CMakeFiles/BSP.dir/Src/fsmc.c.obj CMakeFiles/BSP.dir/Src/dma.c.obj CMakeFiles/BSP.dir/Src/adc.c.obj CMakeFiles/BSP.dir/Src/gpio.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c.obj CMakeFiles/BSP.dir/startup_stm32f407xx.s.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c.obj CMakeFiles/BSP.dir/Src/system_stm32f4xx.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c.obj CMakeFiles/BSP.dir/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c.obj CMakeFiles/BSP.dir/Src/stm32f4xx_hal_msp.c.obj CMakeFiles/BSP.dir/Src/stm32f4xx_it.c.obj CMakeFiles/BSP.dir/Src/main.c.obj CMakeFiles/EmbeddedProject1.dir/dwt_delay.c.obj CMakeFiles/EmbeddedProject1.dir/LcdCust.c.obj CMakeFiles/EmbeddedProject1.dir/ultrasonic.c.obj CMakeFiles/EmbeddedProject1.dir/ili9325.c.obj CMakeFiles/EmbeddedProject1.dir/openx07v_c_lcd.c.obj CMakeFiles/EmbeddedProject1.dir/touch_panel.c.obj CMakeFiles/EmbeddedProject1.dir/font8.c.obj CMakeFiles/EmbeddedProject1.dir/font12.c.obj CMakeFiles/EmbeddedProject1.dir/font16.c.obj CMakeFiles/EmbeddedProject1.dir/font20.c.obj CMakeFiles/EmbeddedProject1.dir/font24.c.obj -o EmbeddedProject1 -“TC:/Users/jpollard_2/Documents/VS2015/Projects/EmbeddedProject1/EmbeddedProject1/STM32F407VGTx_FLASH.ld” -Wl,-Map=EmbeddedProject1.map -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wl,-gc-sections && cd .”
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-sbrkr.o): In function `_sbrk_r’:
    sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-writer.o): In function `_write_r’:
    writer.c:(.text._write_r+0x12): undefined reference to `_write’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-closer.o): In function `_close_r’:
    closer.c:(.text._close_r+0xc): undefined reference to `_close’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-fstatr.o): In function `_fstat_r’:
    fstatr.c:(.text._fstat_r+0x10): undefined reference to `_fstat’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-isattyr.o): In function `_isatty_r’:
    isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-lseekr.o): In function `_lseek_r’:
    lseekr.c:(.text._lseek_r+0x12): undefined reference to `_lseek’
    c:/progra~2/gnutoo~1/72018-~1/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libg.a(lib_a-readr.o): In function `_read_r’:
    readr.c:(.text._read_r+0x12): undefined reference to `_read’
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    • This topic was modified 4 years ago by c3049518.
    • This topic was modified 4 years ago by c3049518.
    Attachments:
    You must be logged in to view attached files.
    #29526
    support
    Keymaster

    Hi,

    Looks like you are missing the semihosting syscalls. Please see the following tutorial for details: https://visualgdb.com/tutorials/arm/semihosting/

    #29527
    c3049518
    Participant

    Thanks that fixed some of the missing files, but I am still getting errors regarding the files in the attached image. The ‘Resolve Build Errors’ wizard suggests including a reference to ‘gloss-linux’ but this has no effect on the errors

    Attachments:
    You must be logged in to view attached files.
    #29529
    support
    Keymaster

    Sorry, VisualGDB cannot automatically fix every possible error in every project. It does its best in suggesting solutions to common errors, but it does not work 100%. Our best advice would be to read more about the role of system calls in embedded projects, understand what component requires them and what implementation suits your requirements the best, and then select the matching implementation as shown in our semihosting tutorial.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.