Page 1 of 1

multiple definitions of 'operator|='

Posted: Sun Sep 15, 2019 1:50 pm
by ppisljar
Recently i installed esp idf on new machine, thus upgraded to latest version with cmake and gcc 8.2.0
however my project now no longer builds. it compiled ok, but when linking i get the following errors:

Code: Select all

/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(c004_timers.o): in function `operator|=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator|='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(c004_timers.o): in function `operator&=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator&='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(c004_timers.o): in function `operator^=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator^='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(c004_timers.o): in function `operator>>=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator>>='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(c004_timers.o): in function `operator<<=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator<<='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(p015_dimmer.o): in function `operator|=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator|='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(p015_dimmer.o): in function `operator&=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator&='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(p015_dimmer.o): in function `operator^=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator^='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(p015_dimmer.o): in function `operator>>=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator>>='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(p015_dimmer.o): in function `operator<<=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator<<='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(rule_engine.o): in function `operator|=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator|='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here
/home/user/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/user/esp/esp32ctrl/build/main/libmain.a(rule_engine.o): in function `operator&=':
/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: multiple definition of `operator&='; /home/user/esp/esp32ctrl/build/main/libmain.a(main.o):/home/user/esp/esp-idf/components/soc/include/hal/timer_types.h:52: first defined here

i tried googling but couldnt find any relevant information. any idea whats going on ?

Re: multiple definitions of 'operator|='

Posted: Sun Sep 15, 2019 6:22 pm
by ppisljar
the code was working with esp-idf 4.0 (with gcc 4.2.0) .... latest version is 4.1 with gcc 8.2.0

Re: multiple definitions of 'operator|='

Posted: Sun Sep 15, 2019 6:23 pm
by ppisljar
the code can be seen here https://github.com/ppisljar/esp32ctrl

Re: multiple definitions of 'operator|='

Posted: Wed Oct 23, 2019 7:46 am
by ESP_michael
Hi ppisljar,

We forgot to add static when defining quick helper function in the header.

Could you please add `static ` at the begining of operator function lines in `esp_attr.h` and have a try? i.e.

https://github.com/espressif/esp-idf/bl ... .h#L84-L94

Re: multiple definitions of 'operator|='

Posted: Sun Nov 17, 2019 8:29 pm
by markbt
Just wanted to say I was having the same problem with the 4.0 release docker image. Adding the static definitions sorted this out.