multiple definition of `premain()' - PlatformIO



  • Hi All,

    I am trying to compile MySensors for STM32F103 using PlatformIO and get following errors. Did anybody encounter such issues?
    Of course all works fine with Arduino IDE.

    Thanks,
    Tom.

    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `premain()':
    main.cpp:(.text.startup._Z7premainv+0x0): multiple definition of `premain()'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup._Z7premainv+0x0): first defined here
    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `main':
    main.cpp:(.text.startup.main+0x0): multiple definition of `main'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup.main+0x0): first defined here
    collect2: error: ld returned 1 exit status
    *** [.pio/build/bluepill_f103c8/firmware.elf] Error 1
    

    My platformio.ini

    [env:bluepill_f103c8]
    ; extra_scripts = pre:fix_main.py
    platform = ststm32
    board = bluepill_f103c8
    board_build.core = maple
    framework = arduino
    
    upload_protocol = stlink
    debug_port = stlink
    debug_tool = stlink
    monitor_port = /dev/cu.usbmodem14103
    monitor_speed = 115200
    monitor_filters = time, default
    lib_deps =     
        MySensors@2.3.2
    

    The code is very simple:

    #include <Arduino.h>
    #define MY_GATEWAY_SERIAL
    #include <MySensors.h>  
    
    void setup() {
      // put your setup code here, to run once:
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    }
    

    Full compilation log:

    
     *  Executing task in folder testbluepill: platformio run --environment bluepill_f103c8 
    
    Processing bluepill_f103c8 (platform: ststm32; board: bluepill_f103c8; framework: arduino)
    ------------------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
    PLATFORM: ST STM32 (15.6.0) > BluePill F103C8
    HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
    DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
    PACKAGES: 
     - framework-arduinoststm32-maple @ 3.10000.201129 (1.0.0) 
     - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 31 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- MySensors @ 2.3.2
    |   |-- Wire @ 1.0
    |   |-- SPI @ 1.0
    |   |-- EEPROM
    Building in release mode
    Linking .pio/build/bluepill_f103c8/firmware.elf
    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `premain()':
    main.cpp:(.text.startup._Z7premainv+0x0): multiple definition of `premain()'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup._Z7premainv+0x0): first defined here
    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `main':
    main.cpp:(.text.startup.main+0x0): multiple definition of `main'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup.main+0x0): first defined here
    collect2: error: ld returned 1 exit status
    *** [.pio/build/bluepill_f103c8/firmware.elf] Error 1
    ======================================================= [FAILED] Took 0.52 seconds =======================================================
    
     *  The terminal process "platformio 'run', '--environment', 'bluepill_f103c8'" terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 
    
     *  Executing task in folder testbluepill: platformio run --environment bluepill_f103c8 
    
    Processing bluepill_f103c8 (platform: ststm32; board: bluepill_f103c8; framework: arduino)
    ------------------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
    PLATFORM: ST STM32 (15.6.0) > BluePill F103C8
    HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
    DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
    PACKAGES: 
     - framework-arduinoststm32-maple @ 3.10000.201129 (1.0.0) 
     - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Library Manager: Installing MySensors @ 2.3.2
    
    Unpacking  [------------------------------------]    0%
    Unpacking  [------------------------------------]    1%
    Unpacking  [------------------------------------]    2%
    Unpacking  [#-----------------------------------]    3%
    Unpacking  [#-----------------------------------]    4%
    Unpacking  [#-----------------------------------]    5%
    Unpacking  [##----------------------------------]    5%
    Unpacking  [##----------------------------------]    6%
    Unpacking  [##----------------------------------]    7%
    Unpacking  [##----------------------------------]    8%
    Unpacking  [###---------------------------------]    8%
    Unpacking  [###---------------------------------]    9%
    Unpacking  [###---------------------------------]   10%
    Unpacking  [####--------------------------------]   11%
    Unpacking  [####--------------------------------]   12%
    Unpacking  [####--------------------------------]   13%
    Unpacking  [#####-------------------------------]   14%
    Unpacking  [#####-------------------------------]   15%
    Unpacking  [#####-------------------------------]   16%
    Unpacking  [######------------------------------]   16%
    Unpacking  [######------------------------------]   17%
    Unpacking  [######------------------------------]   18%
    Unpacking  [######------------------------------]   19%
    Unpacking  [#######-----------------------------]   19%
    Unpacking  [#######-----------------------------]   20%
    Unpacking  [#######-----------------------------]   21%
    Unpacking  [########----------------------------]   22%
    Unpacking  [########----------------------------]   23%
    Unpacking  [########----------------------------]   24%
    Unpacking  [#########---------------------------]   25%
    Unpacking  [#########---------------------------]   26%
    Unpacking  [#########---------------------------]   27%
    Unpacking  [##########--------------------------]   27%
    Unpacking  [##########--------------------------]   28%
    Unpacking  [##########--------------------------]   29%
    Unpacking  [##########--------------------------]   30%
    Unpacking  [###########-------------------------]   30%
    Unpacking  [###########-------------------------]   31%
    Unpacking  [###########-------------------------]   32%
    Unpacking  [############------------------------]   33%
    Unpacking  [############------------------------]   34%
    Unpacking  [############------------------------]   35%
    Unpacking  [############------------------------]   36%
    Unpacking  [#############-----------------------]   36%
    Unpacking  [#############-----------------------]   37%
    Unpacking  [#############-----------------------]   38%
    Unpacking  [##############----------------------]   39%
    Unpacking  [##############----------------------]   40%
    Unpacking  [##############----------------------]   41%
    Unpacking  [###############---------------------]   41%
    Unpacking  [###############---------------------]   42%
    Unpacking  [###############---------------------]   43%
    Unpacking  [###############---------------------]   44%
    Unpacking  [################--------------------]   44%
    Unpacking  [################--------------------]   45%
    Unpacking  [################--------------------]   46%
    Unpacking  [################--------------------]   47%
    Unpacking  [#################-------------------]   47%
    Unpacking  [#################-------------------]   48%
    Unpacking  [#################-------------------]   49%
    Unpacking  [##################------------------]   50%
    Unpacking  [##################------------------]   51%
    Unpacking  [##################------------------]   52%
    Unpacking  [###################-----------------]   52%
    Unpacking  [###################-----------------]   53%
    Unpacking  [###################-----------------]   54%
    Unpacking  [###################-----------------]   55%
    Unpacking  [####################----------------]   55%
    Unpacking  [####################----------------]   56%
    Unpacking  [####################----------------]   57%
    Unpacking  [####################----------------]   58%
    Unpacking  [#####################---------------]   58%
    Unpacking  [#####################---------------]   59%
    Unpacking  [#####################---------------]   60%
    Unpacking  [######################--------------]   61%
    Unpacking  [######################--------------]   62%
    Unpacking  [######################--------------]   63%
    Unpacking  [#######################-------------]   63%
    Unpacking  [#######################-------------]   64%
    Unpacking  [#######################-------------]   65%
    Unpacking  [#######################-------------]   66%
    Unpacking  [########################------------]   66%
    Unpacking  [########################------------]   67%
    Unpacking  [########################------------]   68%
    Unpacking  [########################------------]   69%
    Unpacking  [#########################-----------]   69%
    Unpacking  [#########################-----------]   70%
    Unpacking  [#########################-----------]   71%
    Unpacking  [#########################-----------]   72%
    Unpacking  [##########################----------]   72%
    Unpacking  [##########################----------]   73%
    Unpacking  [##########################----------]   74%
    Unpacking  [###########################---------]   75%
    Unpacking  [###########################---------]   76%
    Unpacking  [###########################---------]   77%
    Unpacking  [############################--------]   78%
    Unpacking  [############################--------]   79%
    Unpacking  [############################--------]   80%
    Unpacking  [#############################-------]   80%
    Unpacking  [#############################-------]   81%
    Unpacking  [#############################-------]   82%
    Unpacking  [#############################-------]   83%
    Unpacking  [##############################------]   83%
    Unpacking  [##############################------]   84%
    Unpacking  [##############################------]   85%
    Unpacking  [###############################-----]   86%
    Unpacking  [###############################-----]   87%
    Unpacking  [###############################-----]   88%
    Unpacking  [################################----]   89%
    Unpacking  [################################----]   90%
    Unpacking  [################################----]   91%
    Unpacking  [#################################---]   91%
    Unpacking  [#################################---]   92%
    Unpacking  [#################################---]   93%
    Unpacking  [#################################---]   94%
    Unpacking  [##################################--]   94%
    Unpacking  [##################################--]   95%
    Unpacking  [##################################--]   96%
    Unpacking  [###################################-]   97%
    Unpacking  [###################################-]   98%
    Unpacking  [###################################-]   99%
    Unpacking  [####################################]  100%
    Library Manager: MySensors@2.3.2 has been installed!
    Found 31 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- MySensors @ 2.3.2
    |   |-- Wire @ 1.0
    |   |-- SPI @ 1.0
    |   |-- EEPROM
    Building in release mode
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/board.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/wirish/boards.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/wirish/boards_setup.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/wirish/start.S.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/wirish/start_c.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduinoVariant/wirish/syscalls.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/HardwareSerial.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/HardwareTimer.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/IPAddress.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/Print.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/Stream.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/WString.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/avr/dtostrf.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/cxxabi-compat.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/ext_interrupts.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/hooks.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/itoa.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/adc.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/adc_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/bkp_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/dac.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/dma.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/dma_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/exc.S.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/exti.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/exti_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/flash.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/fsmc_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/gpio.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/gpio_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/i2c.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/i2c_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/iwdg.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/nvic.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/pwr.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/rcc.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/rcc_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/spi.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/spi_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/stm32f1/performance/isrs.S.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/stm32f1/performance/vector_table.S.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/systick.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/timer.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/timer_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usart.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usart_f1.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usart_private.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/stm32f1/usb.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/stm32f1/usb_cdcacm.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/stm32f1/usb_reg_map.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/usb_lib/usb_core.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/usb_lib/usb_init.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/usb_lib/usb_mem.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/usb/usb_lib/usb_regs.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/libmaple/util.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/new.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/pwm.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/sdio.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/stm32f1/util_hooks.c.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/stm32f1/wiring_pulse_f1.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/stm32f1/wirish_debug.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/stm32f1/wirish_digital_f1.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/tone.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/usb_serial.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/wirish_analog.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/wirish_digital.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/wirish_math.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/wirish_shift.cpp.o
    Compiling .pio/build/bluepill_f103c8/FrameworkArduino/wirish_time.cpp.o
    Compiling .pio/build/bluepill_f103c8/src/main.cpp.o
    Compiling .pio/build/bluepill_f103c8/lib9ba/Wire/SoftWire.cpp.o
    Compiling .pio/build/bluepill_f103c8/lib9ba/Wire/Wire.cpp.o
    Compiling .pio/build/bluepill_f103c8/lib9ba/Wire/utility/WireBase.cpp.o
    Compiling .pio/build/bluepill_f103c8/liba01/SPI/SPI.cpp.o
    Compiling .pio/build/bluepill_f103c8/lib781/EEPROM/EEPROM.cpp.o
    Compiling .pio/build/bluepill_f103c8/lib781/EEPROM/flash_stm32.c.o
    Compiling .pio/build/bluepill_f103c8/libad4/MySensors/MyASM.S.o
    Archiving .pio/build/bluepill_f103c8/libad4/libMySensors.a
    Indexing .pio/build/bluepill_f103c8/libad4/libMySensors.a
    Archiving .pio/build/bluepill_f103c8/lib9ba/libWire.a
    Indexing .pio/build/bluepill_f103c8/lib9ba/libWire.a
    Archiving .pio/build/bluepill_f103c8/lib781/libEEPROM.a
    Indexing .pio/build/bluepill_f103c8/lib781/libEEPROM.a
    Archiving .pio/build/bluepill_f103c8/liba01/libSPI.a
    Indexing .pio/build/bluepill_f103c8/liba01/libSPI.a
    Linking .pio/build/bluepill_f103c8/firmware.elf
    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `premain()':
    main.cpp:(.text.startup._Z7premainv+0x0): multiple definition of `premain()'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup._Z7premainv+0x0): first defined here
    .pio/build/bluepill_f103c8/src/main.cpp.o: In function `main':
    main.cpp:(.text.startup.main+0x0): multiple definition of `main'
    .pio/build/bluepill_f103c8/FrameworkArduino/main.cpp.o:main.cpp:(.text.startup.main+0x0): first defined here
    collect2: error: ld returned 1 exit status
    *** [.pio/build/bluepill_f103c8/firmware.elf] Error 1
    ======================================================= [FAILED] Took 4.22 seconds =======================================================
    
     *  The terminal process "platformio 'run', '--environment', 'bluepill_f103c8'" terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 
    


  • Well, search seems to be broken again on the site. Hopefully a dev will see this come across their screen and know how to fix it.

    I searched the site for "multiple definition" and 'premain' but neither one got ANY hits, even this topic itself!

    So if you tried to search the site to see if anyone else had had this problem before, it wouldn't have much chance of success. Anyway, all that is to say that we've run into this before. I'll link below here the thread where I managed to get around it. I'm not sure if there were other threads, but this one should give you some info on how to fix it for yourself. I could find this by going into the history of posts I had made, since search was failing me.... 🙂

    https://forum.mysensors.org/topic/10193/stm32f103c8-problem-at-compilation


Log in to reply
 

Suggested Topics

  • 3
  • 1
  • 6
  • 2

69
Online

11.4k
Users

11.1k
Topics

112.7k
Posts