Electronics > Microcontrollers

Rpi linker error for GitHub repo

(1/1)

Wiljan:
I have a Rpi4 running


--- Code: ---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
--- End code ---

From terminal I have done:

--- Code: ---git clone https://github.com/dansarie/sboxgates

--- End code ---


--- Code: ---sudo apt-get install cmake graphviz libmpich-dev libxml2-dev mpich
mkdir build
cd build
cmake ..
make
--- End code ---

When make does run the linker fail with

--- Code: ---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 $
--- End code ---

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

Thank you


newbrain:

--- Quote from: Wiljan on August 13, 2022, 02:21:25 pm ---I would assume that the code should work as is from the GitHub?

--- End quote ---
:-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: ---extern uint8_t g_sbox_enc[256];
--- End code ---
and add a definition in sboxgates.c:

--- Code: ---uint8_t g_sbox_enc[256];
--- End code ---

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).

SiliconWizard:
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

Wiljan:

--- Quote from: newbrain on August 13, 2022, 07:19:44 pm ---
--- Quote from: Wiljan on August 13, 2022, 02:21:25 pm ---I would assume that the code should work as is from the GitHub?

--- End quote ---
:-DD
Funniest thing I read today!

--- End quote ---
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

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version