PX4 / sapog

Sapog - advanced multiplatform ESC firmware

Home Page:https://kb.zubax.com/x/cYAh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined reference to `main'

dusan19 opened this issue · comments

When I compile the main binary using the make command the following error comes up

build/obj/crt0_v7m.o: In function `endinitloop':
(.text+0x74): undefined reference to `main'
collect2: error: ld returned 1 exit status

I am using the gcc version 4.9:
gcc version 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 227977] (GNU Tools for ARM Embedded Processors)

how can i fix this problem?

Please make clean, then make, and then post the full build log.

Compiler Options
arm-none-eabi-gcc -c -mcpu=cortex-m3 -falign-functions=16 -U__STRICT_ANSI__ -fno-exceptions -fno-unwind-tables -fno-stack-protector -fno-builtin-printf -fno-builtin-fprintf -fno-builtin-vprintf -fno-builtin-vfprintf -fno-builtin-puts -u_port_lock -u_port_unlock -u_exit -u_kill -u_getpid -uchThdExit -u__errno -nodefaultlibs -lc -lgcc -lm -O2 -g3 -DDISABLE_WATCHDOG=1 -ffunction-sections -fdata-sections -fno-common -flto -std=c99 -Wshadow -Wpointer-arith -Wno-packed -Wno-attributes -Wno-error=undef -Wno-error=shadow -Werror -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/lst/ -DCORTEX_VTOR_INIT=16384 -DCRT1_AREAS_NUMBER=0 -DCONFIG_PARAMS_MAX=50 -DDEBUG_BUILD=1 -Dasm=__asm -DCORTEX_USE_FPU=FALSE -DFW_VERSION_MAJOR=2 -DFW_VERSION_MINOR=2 -DHW_VERSION_MAJOR=1 -DNODE_NAME="io.px4.sapog" -DCONFIG_PARAM_MAX_NAME_LENGTH=16 -DUAVCAN_STM32_TIMER_NUMBER=7 -DUAVCAN_STM32_NUM_IFACES=2 -DUAVCAN_CPP_VERSION=UAVCAN_CPP11 -DUAVCAN_STM32_CHIBIOS=1 -DGIT_HASH=0x7719d6e -DSTDOUT_SD=SD1 -DSTDIN_SD=STDOUT_SD -DSERIAL_CLI_PORT_NUMBER=1 -DCORTEX_ENABLE_WFI_IDLE=1 -fno-single-precision-constant -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/build.d -I. -Izubax_chibios///chibios/os/rt/ports/ARMCMx -Izubax_chibios///chibios/os/rt/ports/ARMCMx/compilers/GCC -Izubax_chibios///chibios/os/rt/include -Izubax_chibios///chibios/os/hal/include -Izubax_chibios//chibios/os/hal/ports/common/ARMCMx -Izubax_chibios//chibios/os/hal/ports/STM32/STM32F1xx -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/CANv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/DACv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/DMAv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/EXTIv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/GPIOv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/I2Cv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/MACv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/OTGv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/RTCv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/SDIOv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/SPIv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/TIMv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/USARTv1 -Izubax_chibios//chibios/os/hal/ports/STM32/LLD/xWDGv1 -Izubax_chibios///chibios/os/various/cpp_wrappers -Izubax_chibios///chibios/os/common/ports/ARMCMx/compilers/GCC -Izubax_chibios///chibios/os/common/ports/ARMCMx/devices/STM32F1xx -Izubax_chibios///chibios/os/ext/CMSIS/include -Izubax_chibios///chibios/os/ext/CMSIS/ST/STM32F1xx -Izubax_chibios///chibios/os/hal/osal/rt -Izubax_chibios///chibios/os/various -Izubax_chibios///chibios/os/hal/lib/streams -Isrc -Isrc/os_config -Ilibuavcan/libuavcan/include -Ilibuavcan/libuavcan_drivers/stm32/driver/include/ -Idsdlc_generated -Izubax_chibios// main.c -o main.o

Compiling crt0_v7m.s
Compiling chcoreasm_v7m.s
Compiling crt1.c
Compiling vectors.c
Compiling chsys.c
Compiling chdebug.c
Compiling chvt.c
Compiling chschd.c
Compiling chthreads.c
Compiling chtm.c
Compiling chstats.c
Compiling chdynamic.c
Compiling chregistry.c
Compiling chsem.c
Compiling chmtx.c
Compiling chcond.c
Compiling chevents.c
Compiling chmsg.c
Compiling chmboxes.c
Compiling chqueues.c
Compiling chmemcore.c
Compiling chheap.c
Compiling chmempools.c
Compiling chcore.c
Compiling chcore_v7m.c
Compiling osal.c
Compiling hal.c
Compiling hal_buffers.c
Compiling hal_queues.c
Compiling hal_mmcsd.c
Compiling adc.c
Compiling can.c
Compiling dac.c
Compiling ext.c
Compiling gpt.c
Compiling i2c.c
Compiling i2s.c
Compiling icu.c
Compiling mac.c
Compiling mmc_spi.c
Compiling pal.c
Compiling pwm.c
Compiling rtc.c
Compiling sdc.c
Compiling serial.c
Compiling serial_usb.c
Compiling spi.c
Compiling st.c
Compiling uart.c
Compiling usb.c
Compiling wdg.c
Compiling nvic.c
Compiling hal_lld.c
Compiling adc_lld.c
Compiling ext_lld_isr.c
Compiling can_lld.c
Compiling dac_lld.c
Compiling stm32_dma.c
Compiling ext_lld.c
Compiling pal_lld.c
Compiling i2c_lld.c
Compiling mac_lld.c
Compiling usb_lld.c
Compiling rtc_lld.c
Compiling sdc_lld.c
Compiling spi_lld.c
Compiling gpt_lld.c
Compiling icu_lld.c
Compiling pwm_lld.c
Compiling st_lld.c
Compiling serial_lld.c
Compiling uart_lld.c
Compiling wdg_lld.c
Compiling syscalls.c
Compiling chprintf.c
Compiling memstreams.c
Compiling shell.c
Compiling uc_data_type.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_dynamic_node_id_client.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_node_status_provider.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_error.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_scalar_codec.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_float_spec.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_bit_stream.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_bit_array_copy.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_dynamic_memory.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_global_data_type_registry.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_service_client.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_timer.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_generic_subscriber.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_scheduler.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_generic_publisher.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_can.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_transfer_receiver.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_transfer_buffer.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_dispatcher.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_crc.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_outgoing_transfer_registry.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_can_io.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_transfer_listener.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_transfer.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_transfer_sender.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_can_acceptance_filter_configurator.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_frame.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling uc_stm32_clock.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from libuavcan/libuavcan/include/uavcan/marshal/types.hpp:10:0,
                 from dsdlc_generated/uavcan/Timestamp.hpp:14,
                 from libuavcan/libuavcan/include/uavcan/time.hpp:12,
                 from libuavcan/libuavcan/include/uavcan/driver/system_clock.hpp:11,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/clock.hpp:8,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp:5:
libuavcan/libuavcan/include/uavcan/marshal/array.hpp: In instantiation of 'uavcan::Array<T, ArrayMode, MaxSize_>::SelfType& uavcan::Array<T, ArrayMode, MaxSize_>::operator=(const char*) [with T = uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>; uavcan::ArrayMode ArrayMode = (uavcan::ArrayMode)1u; unsigned int MaxSize_ = 80u; uavcan::Array<T, ArrayMode, MaxSize_>::SelfType = uavcan::Array<uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>, (uavcan::ArrayMode)1u, 80u>]':
libuavcan/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp:82:29:   required from here
libuavcan/libuavcan/include/uavcan/marshal/array.hpp:828:15: warning: declaration of 'ch' shadows a global declaration [-Wshadow]
     SelfType& operator=(const char* ch)
               ^
In file included from zubax_chibios///chibios/os/rt/include/ch.h:78:0,
                 from zubax_chibios///chibios/os/various/cpp_wrappers/ch.hpp:25,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp:10,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp:6:
zubax_chibios///chibios/os/rt/include/chschd.h:521:20: note: shadowed declaration is here
 extern ch_system_t ch;
                    ^
Compiling uc_stm32_can.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from libuavcan/libuavcan/include/uavcan/marshal/types.hpp:10:0,
                 from dsdlc_generated/uavcan/Timestamp.hpp:14,
                 from libuavcan/libuavcan/include/uavcan/time.hpp:12,
                 from libuavcan/libuavcan/include/uavcan/uavcan.hpp:11,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp:26,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp:8,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp:7:
libuavcan/libuavcan/include/uavcan/marshal/array.hpp: In instantiation of 'uavcan::Array<T, ArrayMode, MaxSize_>::SelfType& uavcan::Array<T, ArrayMode, MaxSize_>::operator=(const char*) [with T = uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>; uavcan::ArrayMode ArrayMode = (uavcan::ArrayMode)1u; unsigned int MaxSize_ = 80u; uavcan::Array<T, ArrayMode, MaxSize_>::SelfType = uavcan::Array<uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>, (uavcan::ArrayMode)1u, 80u>]':
libuavcan/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp:82:29:   required from here
libuavcan/libuavcan/include/uavcan/marshal/array.hpp:828:15: warning: declaration of 'ch' shadows a global declaration [-Wshadow]
     SelfType& operator=(const char* ch)
               ^
In file included from zubax_chibios///chibios/os/rt/include/ch.h:78:0,
                 from zubax_chibios///chibios/os/various/cpp_wrappers/ch.hpp:25,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp:10,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp:8,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp:7:
zubax_chibios///chibios/os/rt/include/chschd.h:521:20: note: shadowed declaration is here
 extern ch_system_t ch;
                    ^
Compiling uc_stm32_thread.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from libuavcan/libuavcan/include/uavcan/marshal/types.hpp:10:0,
                 from dsdlc_generated/uavcan/Timestamp.hpp:14,
                 from libuavcan/libuavcan/include/uavcan/time.hpp:12,
                 from libuavcan/libuavcan/include/uavcan/uavcan.hpp:11,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp:26,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_thread.cpp:5:
libuavcan/libuavcan/include/uavcan/marshal/array.hpp: In instantiation of 'uavcan::Array<T, ArrayMode, MaxSize_>::SelfType& uavcan::Array<T, ArrayMode, MaxSize_>::operator=(const char*) [with T = uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>; uavcan::ArrayMode ArrayMode = (uavcan::ArrayMode)1u; unsigned int MaxSize_ = 80u; uavcan::Array<T, ArrayMode, MaxSize_>::SelfType = uavcan::Array<uavcan::IntegerSpec<8u, (uavcan::Signedness)0u, (uavcan::CastMode)0u>, (uavcan::ArrayMode)1u, 80u>]':
libuavcan/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp:82:29:   required from here
libuavcan/libuavcan/include/uavcan/marshal/array.hpp:828:15: warning: declaration of 'ch' shadows a global declaration [-Wshadow]
     SelfType& operator=(const char* ch)
               ^
In file included from zubax_chibios///chibios/os/rt/include/ch.h:78:0,
                 from zubax_chibios///chibios/os/various/cpp_wrappers/ch.hpp:25,
                 from libuavcan/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp:10,
                 from libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_thread.cpp:5:
zubax_chibios///chibios/os/rt/include/chschd.h:521:20: note: shadowed declaration is here
 extern ch_system_t ch;
                    ^
Compiling sys_stm32.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling watchdog_stm32.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
zubax_chibios///zubax_chibios/platform/stm32/watchdog_stm32.cpp: In function 'void setTimeout(unsigned int)':
zubax_chibios///zubax_chibios/platform/stm32/watchdog_stm32.cpp:62:18: note: #pragma message: WARNING: Watchdog is disabled!
 # pragma message "WARNING: Watchdog is disabled!"
                  ^
Compiling libstdcpp.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling sys_console.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling sys.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling config.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling config_cli.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling ch.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Compiling syscalls_cpp.cpp
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
Linking build/io.px4.sapog.elf
build/obj/crt0_v7m.o: In function `endinitloop':
(.text+0x74): undefined reference to `main'
collect2: error: ld returned 1 exit status
zubax_chibios///chibios/os/common/ports/ARMCMx/compilers/GCC/rules.mk:243: recipe for target 'build/io.px4.sapog.elf' failed
make: *** [build/io.px4.sapog.elf] Error 1

Okay, thank you, I'm also going to need the output of git status

git status

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

git log

commit 7719d6eca45dc85d6d747012bc6bbea0aa57d7ee
Author: Pavel Kirienko <pavel.kirienko@gmail.com>
Date:   Tue Dec 12 22:44:46 2017 +0200

    Minor ardubenchmark updates on the host side

This is exceptionally weird. I am using exactly the same build of GCC 4.9 on Mint 18 AMD64, and it builds the codebase fine (always did). You appear to have initialized all of the submodules correctly, so the problem is not there.

Could you check if you can reproduce the problem with GCC 6.3? It compiles the code on my machine fine. If that doesn't help, you should perhaps raise this issue with GCC maintainers.

Closing as stale; please reopen if you have more information.

Similar bug report here: https://forum.zubax.com/t/sapog-make-firmware/894/7

I have no idea what is going on; everything works well for me. For now, consider using the Bistromathic VM: https://kb.zubax.com/x/KIEh