简体   繁体   中英

“multiple definition of `main'” error when compiling a mbed OS program

I have compiled a test and got lots of errors. I have no idea what it is. Anyone can explain please.

D:\Projects\mbed-os-example-blinky-master>mbed test -m ublox_c030_u201 -t gcc_arm --compile

Build failures:
  * UBLOX_C030_U201::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-CONNECTIVITY
        Building project connectivity (UBLOX_C030_U201, GCC_ARM)
        Scan: gcc_arm
        Scan: connectivity
        Scan: FEATURE_LWIP
        Link: connectivity
        D:/Projects/mbed-os-example-blinky-master/BUILD/tests/ublox_c030_u201/gcc_arm/main.o: In function `main':
        main.cpp:(.text.startup.main+0x0): multiple definition of `main'
        D:/Projects/mbed-os-example-blinky-master/BUILD/tests/ublox_c030_u201/gcc_arm/./mbed-os/features/FEATURE_LWIP/TESTS/mbedmicro-net/connectivity/./main.o:main.cpp:(.text.startup.main+0x0): first defined here
        collect2.exe: error: ld returned 1 exit status


[mbed] ERROR: "c:\python27\python.exe" returned error code 1.
[mbed] ERROR: Command "c:\python27\python.exe -u D:\Projects\mbed-os-example-blinky-master\mbed-os\tools\test.py -t gcc_arm -m ublox_c030_u201 --source D:\Projects\mbed-os-example-blinky-master --build D:\Projects\mbed-os-example-blinky-master\BUILD\tests\ublox_c030_u201\gcc_arm --test-spec D:\Projects\mbed-os-example-blinky-master\BUILD\tests\ublox_c030_u201\gcc_arm\test_spec.json" in "D:\Projects\mbed-os-example-blinky-master"

You are compiling the tests for this target, while you also have your own program. That won't work as both the tests and your program have a main function.

Instead do:

mbed compile -m ublox_c030_u201 -t gcc_arm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM