Can't use Dynamixel SDK on Raspberry PI

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.

1 Like

thank you very much, i will look forward for your answer.

@xiasha , @watchieboy

I think that I figured out the problem, although you may not like the solution.

Essentially, the problem is the RPi OS used:

  • When I used BULLSEYE OS, I got the same errors as shown by xiasha.

  • But if I used BUSTER OS, then no problem at all with “make” and “sudo make install” - see pictures below:

So for now, you will need to stay with BUSTER if you want to use DXL SDK, therefore some new features from BULLSEYES are not available.

I am mentioning this issue to @Jonathon and @willson too, so that they know what to look for when it is time to upgrade DXL SDK to BULLSEYE OS.

Ok, i am going to try with BUSTER OS, thank you so much. have a nice weekend.

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.

1 Like

Hi Bottango,

Thank for your answer, finally, i have reinstalled the BUSTER OS and it works correctly.

@Bottango
Great tip! I have learned something new too! Thank you!

Using -fcommon doesn’t help with the current Rasbian (bookworm). Is the only way to get it working on a Pi to find areally old install of Buster?

Some months back I did ok with bookworm and Rpi 5 and 4b. Please see this post.

What were the errors? It would not generate the proper binary files?

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
image

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.

Yeah! :ok_hand:
Glad to hear that things are working out for you too.

1 Like