Rpi linker error for GitHub repo - Page 1
Forum section: electronics / general

author: Wiljan
author_rank: Regular Contributor
timestamp: August 13, 2022, 02:21:25 pm
content: I have a Rpi4 runningCode:PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"NAME="Raspbian GNU/Linux"VERSION_ID="11"VERSION="11 (bullseye)"VERSION_CODENAME=bullseyeID=raspbianID_LIKE=debianFrom terminal I have done:Code:git clone https://github.com/dansarie/sboxgatesCode:sudo apt-get install cmake graphviz libmpich-dev libxml2-dev mpichmkdir buildcd buildcmake ..makeWhen make does run the linker fail withCode: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 herecollect2: error: ld returned 1 exit statusmake: *** [CMakeFiles/sboxgates.dir/build.make:165: sboxgates] Error 1make: *** [CMakeFiles/Makefile2:95: CMakeFiles/sboxgates.dir/all] Error 2make: *** [Makefile:149: all] Error 2pi@raspberrypi:~/sboxgates/build $I understand there is aQuotebut I would assume that the code should work as is from the GitHub?Please advise what I need to change?Thank you

author: newbrain
author_rank: Super Contributor
timestamp: August 13, 2022, 07:19:44 pm
content: Quote from: Wiljan on August 13, 2022, 02:21:25 pmFunniest thing I read today!Yes, at a quick glanceg_sbox_encisdefinedmultiple 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;and add a definition in sboxgates.c:Code:uint8_t g_sbox_enc;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).

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 13, 2022, 10:21:27 pm
content: 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

author: Wiljan
author_rank: Regular Contributor
timestamp: August 13, 2022, 10:22:55 pm
content: Quote from: newbrain on August 13, 2022, 07:19:44 pmHehe yeah I just assumed when the author did write exactly how to build it all it would workI did change according your suggesting and now it build fine, thank youI will now have to see if it can help me on some sbox reduction