CPP Linux
Compiler and Builder
Compiler
- GNU gcc ver. 5.4.0 20160609 or higher
-
To check the version of your gcc compiler:
$ gcc -v
-
Download the required compiler:
$ sudo apt-get install gcc-5
Builder
- Build-essential pkg → make
-
Download:
$ sudo apt-get install build-essential
Dependent Packages
- Packages needed for cross-compiling
-
Download:
$ sudo apt-get install gcc-multilib g++-multilib
Build the Library
-
Choose which format (32bit or 64bit) do you want to build in. The Makefile is located in the following folder:
[DynamixelSDK folder]/cpp/build/linux32
OR[DynamixelSDK folder]/cpp/build/linux64
folder for 64-bit platforms OR[DynamixelSDK folder]/cpp/build/linux_sbc
folder for SBCs.Please note that if you will be building the 32-bit example source, you should build the 32-bit library.
-
Go to the Makefile’s directory located in
[DynamixelSDK folder]/cpp/build/linux32
OR[DynamixelSDK folder]/cpp/build/linux64
OR[DynamixelSDK folder]/cpp/build/linux_sbc
using $cd
. -
To build the library file:
$ make
-
If there is an error:
$ make clean && make
-
To delete the library file and object files:
$ make clean
Copy (Install) the Library to the Root Directory
-
To make library file and copy it to the root directory (to handle the serial port):
$ sudo make install
-
If there is an error:
$ sudo make uninstall && sudo make install
OR
$ sudo make reinstall
-
To delete the library file from the root directory:
$ sudo make uninstall
-
To recopy the library file to the root directory:
$ sudo make reinstall
-
You will see the built library file in
[DynamixelSDK folder]/c/build/[linuxXX]/libdxl_xYY_cpp.so
Building and Running the Sample Code
The DYNAMIXEL SDK sample code for CPP uses the library files(.so for Linux) built in CPP language.
You should build library files in [DynamixelSDK folder]/c++/build/[linuxXX]/libdxl_xYY_cpp.so
with its own source code as shown above.
-
Choose which format (32bit or 64bit) do you want to build in. The Makefile file for building source is in
[DynamixelSDK folder]/c++/example/protocol1.0/read_write/linux32
or[DynamixelSDK folder]/c++/example/protocol1.0/read_write/linux64
folder. If you want to build example source in 32bit, for instance, you should build this library in 32bit as well. -
On the terminal, go to the Makefile located folder
/c++/example/protocol1.0/read_write/linux32
, for example, usingcd
. -
To build executable file, type:
$ make
If it shows some error, try make clean
and make
it again.
-
To delete executable file, type:
$ make clean
-
Make the port available to be used
$ sudo chmod a+rw /dev/ttyUSB0
-
Run the source code
$ ./read_write