-1

https://github.com/ABHIRAMSHIBU/rpimultiboot/
I have this code, currently I didn't polish it at all because its under development. But I am having an issue with compiling this. I have a sdcard with raspbean. If I put the sdcard into raspberry pi 3 and compile this, it works but if I put the sdcard and compile in raspberry pi 4, it puts out this error with linking

/usr/bin/ld: test: in function `partitionOK':
:(.text+0xf0): multiple definition of `partitionOK'; /tmp/ccMcfdbw.o:test.c:(.text+0x0): first defined here
/usr/bin/ld: test: in function `_fini':
:(.fini+0x0): multiple definition of `_fini'; /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crti.o:(.fini+0x0): first defined here
/usr/bin/ld: test: in function `__data_start':
:(.data+0x0): multiple definition of `__data_start'; /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o:(.data+0x0): first defined here
/usr/bin/ld: test: in function `__data_start':
:(.data+0x4): multiple definition of `__dso_handle'; /usr/lib/gcc/arm-linux-gnueabihf/8/crtbegin.o:(.data+0x0): first defined here
/usr/bin/ld: test:(.rodata+0x0): multiple definition of `_IO_stdin_used'; /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o:(.rodata.cst4+0x0): first defined here
/usr/bin/ld: test: in function `_start':
:(.text+0x0): multiple definition of `_start'; /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o:(.text+0x0): first defined here
/usr/bin/ld: test: in function `main':
:(.text+0x1ac): multiple definition of `main'; /tmp/ccMcfdbw.o:test.c:(.text+0xbc): first defined here
/usr/bin/ld: test: in function `printhelp':
:(.text+0x178): multiple definition of `printhelp'; /tmp/ccMcfdbw.o:test.c:(.text+0x88): first defined here
/usr/bin/ld: test: in function `_init':
:(.init+0x0): multiple definition of `_init'; /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crti.o:(.init+0x0): first defined here
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'; test::(.data+0x8): first defined here
collect2: error: ld returned 1 exit status

Hope you will help me, thanks in advance.
To compile..
git clone https://github.com/ABHIRAMSHIBU/rpimultiboot/
cd rpimultiboot
gcc test.c -o test

If properly compiled

sudo ./test -p [partitionNumberOfAlterativeBootPartition]

for example if you have mmcblk0p3 then use -p 3 Now the pi should technically boot into that partition. :-)

Dirk
  • 3,541
  • 3
  • 18
  • 25
  • Ok people are going to down vote my genuine question then, no issue. This is why I hate stack overflow and all these types of forum. I will bring up my own forum... – Abhiram Shibu Nov 17 '20 at 12:36

1 Answers1

1

Compiling with add -fcommon to CFLAGS made it work. Got this answer from raspberry pi forums after posting it there

Try CFLAGS="-fcommon" gcc test.c -o test

  • Please mark the answer as the accepted one with a click on the tick on its left side. That prevents your Question from being shown as an unsolved Post to the community and saves them/us a lot of work. – Ingo Nov 22 '20 at 11:28