I have ordered XM430-W350-R servos, but they have not arrived yet. I wanted to set up everything so that it will work as soon as they arrive. I cloned the Github SDK repo, and I will be using C on a Raspberry PI 4B. However, when I go to DynamixelSDK/c/build/linux_sbc and run “make” in the terminal, it doesn’t build. I get a bunch of “multiple definition” errors, such as this one:
/usr/bin/ld: ./.objects/packet_handler.o:/home/user_name/DynamixelSDK/c/build/linux_sbc/../../include/dynamixel_sdk/port_handler.h:47: multiple definition of `g_used_port_num';
./.objects/group_bulk_read.o:/home/user_name/DynamixelSDK/c/build/linux_sbc/../../include/dynamixel_sdk/port_handler.h:47: first defined here
When I run the corresponding make command on my mac (from DynamixelSDK/c/build/mac) it works fine. Why doesn’t it work on the Raspberry PI?
EDIT: I fixed the issue. The problem was that the variables defined in packet_handler.h:82, port_handler.h:47 and port_handler.h:48 became redefined in different source file. By declaring each of those variables as extern, the problem was fixed and I can now compile and link the files. Robotis should change this in the SDK, so that no one else has to sit through and debug it like I had to.
I used the video/procedures mentioned at this “QuickStart” post and I did not have any problem at all with an RPi-4B. I did compile both for C and C++, although so far, I only used C++.
I used the above procedures in this project which worked out OK for me (I did use C++ though).
I have the same problem with [watchieboy], although i change the type of variables as extern, it does not work, the error message is
/usr/bin/ld: /usr/local/lib/libdxl_sbc_c.so: reference to g_used_port_num' undefinid /usr/bin/ld: /usr/local/lib/libdxl_sbc_c.so: reference to packetData’ undefined
/usr/bin/ld: /usr/local/lib/libdxl_sbc_c.so: reference to `g_is_using’ undefined
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: read_write] Error 1
Back in 2021, I did not have any such issue with RPi-4B and DXL-SDK, but I will revisit my old RPi-4B projects with an updated RPi OS to see what is going on. I expect quite a few “broken” things to be fixed, so I’ll let you know about my progress, hopefully in a couple of weeks.
I was running into the same issue compiling the c library on Ubuntu, but I believe it comes down to your version of gcc. The docs say use gcc version 5 or later, however starting in version 10 gcc defaults to -fno-common. If your gcc is more recent than that I believe is the source of the compilation error. Just adding extern I found doesn’t solve the root problem.
Adding “-fcommon” to the cflags in the c make file allowed me to successfully compile the c library and I was able to test it working successfully on my project on the target platform.
I’ve followed the post you linked, I’ve tried the C/C++ and Python installs, all without success. With the C version I added the -fcommon to the ccflags and cxflags lines.
I get a whole load of “multiple definition of … first defined here” messages and finally an “collect2: error: ld returned 1 exit status”
"[Makefile:68: libdxl_sbc_c.so] Error 1
Ok, so that’s weird. I wiped everything and started again and the compile worked!
modified addresses and movement ranges in the sync_read_write and we have movement.