Author Topic: Rpi linker error for GitHub repo  (Read 724 times)

0 Members and 1 Guest are viewing this topic.

Offline WiljanTopic starter

  • Regular Contributor
  • *
  • Posts: 230
  • Country: dk
Rpi linker error for GitHub repo
« on: August 13, 2022, 02:21:25 pm »
I have a Rpi4 running

Code: [Select]
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian

From terminal I have done:
Code: [Select]
git clone https://github.com/dansarie/sboxgates

Code: [Select]
sudo apt-get install cmake graphviz libmpich-dev libxml2-dev mpich
mkdir build
cd build
cmake ..
make

When make does run the linker fail with
Code: [Select]
pi@raspberrypi:~/sboxgates/build $ make
[ 16%] Linking C executable sboxgates
/usr/bin/ld: CMakeFiles/sboxgates.dir/lut.c.o (symbol from plugin): in function `check_n_lut_possible':
(.text+0x0): multiple definition of `g_sbox_enc'; CMakeFiles/sboxgates.dir/convert_graph.c.o (symbol from plugin):(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sboxgates.dir/sboxgates.c.o (symbol from plugin): in function `g_mpi_work_type':
(.text+0x0): multiple definition of `g_sbox_enc'; CMakeFiles/sboxgates.dir/convert_graph.c.o (symbol from plugin):(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sboxgates.dir/state.c.o (symbol from plugin): in function `save_state':
(.text+0x0): multiple definition of `g_sbox_enc'; CMakeFiles/sboxgates.dir/convert_graph.c.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sboxgates.dir/build.make:165: sboxgates] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/sboxgates.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
pi@raspberrypi:~/sboxgates/build $

I understand there is a
Quote
multiple definition of `g_sbox_enc';
but I would assume that the code should work as is from the GitHub?
Please advise what I need to change?

Thank you


 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1765
  • Country: se
Re: Rpi linker error for GitHub repo
« Reply #1 on: August 13, 2022, 07:19:44 pm »
I would assume that the code should work as is from the GitHub?
:-DD
Funniest thing I read today!

Yes, at a quick glance g_sbox_enc is defined multiple times, as the linker notices.

Just add extern to its tentative definition in sboxgates.h, changing it into a declaration:
Code: [Select]
extern uint8_t g_sbox_enc[256]; and add a definition in sboxgates.c:
Code: [Select]
uint8_t g_sbox_enc[256];
This, in the assumption that that object needs to be shared across translation units instead of being a separate object for each file.
(I have not read the code nor do I intend to read/try/debug it).
« Last Edit: August 13, 2022, 10:08:43 pm by newbrain »
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15244
  • Country: fr
Re: Rpi linker error for GitHub repo
« Reply #2 on: August 13, 2022, 10:21:27 pm »
It may have built successfully with older versions of GCC - it used to silently accept multiple tentative definitions such as this, but it doesn't anymore by default - there is an option flag  you can enable, though fixing the source code sounds like a better idea.

See there: https://gcc.gnu.org/gcc-10/porting_to.html
 
The following users thanked this post: Wiljan

Offline WiljanTopic starter

  • Regular Contributor
  • *
  • Posts: 230
  • Country: dk
Re: Rpi linker error for GitHub repo
« Reply #3 on: August 13, 2022, 10:22:55 pm »
I would assume that the code should work as is from the GitHub?
:-DD
Funniest thing I read today!
Hehe yeah I just assumed when the author did write exactly how to build it all it would work  ::)

I did change according your suggesting and now it build fine, thank you  :-+

I will now have to see if it can help me on some sbox reduction
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf