Compile and run myCobotCpp
Download
Source code download
Download MycobotCpp from github.
Dynamic library download
Dependency library download (Download the latest version, pay attention to select Windows or Linux, the suffix .zip is the library required for Windows, and .tar.gz is the library required for Linux)
Run under Windows
Compile
Open MycobotCpp in vs2019, select x64-Release to compile (next to the startup item, if not, click the drop-down box--》Manage Configuration to add it), and also select release in the configuration of cmake settings, and finally click Generate. Note: Be sure to select x64-Release for compilation, as shown in the figure below:
Run
- Add library files: add .lib to myCobotCpp/lib, and add .lib and .dll to the same directory as myCobotCppExample.exe, such as out/build/x64-Release/bin (.lib and .dll are in the myCobotCpp-0.0.3-windows-msvc-x86_64.zip compressed package)
- Run: Select Startup (next to the green play button, that is, next to the Run button), pull down and select myCobotCppEXample.exe (bin\myCobotCppExample.exe), and click Run, as shown in the figure below:
Common problems and solutions:
Runtime error: - If myCobotCpp.dll is missing, put the myCobotCpp.dll previously placed in the lib directory into the directory where mycobotcppexample.exe is located
- If QT5Core.dll is missing, open qt command (search QT in the menu bar), select msvc 2017 64-bit, and execute windeployqt --release to the directory where myCobotCppExample.exe is located (such as: windeployqt --release D:\vs2019\myCobotCpp\out\build\x64-Release\bin) If the vs installation path is not found after executing the command here, please check the settings of vs environment variables
- After executing the above steps, if the qt5serialport.dll file is missing, copy this file in the qt installation directory (path such as: D:\qt5.12.10\5.12.10\msvc2017_64\bin) to the directory where myCobotCppExample.exe is located
Run under Linux
Compile and build
- mkdir build && cd build
- cmake ..
- cmake --build .
Run
- Copy all .so files to the lib directory
- Run the command line: ./bin/myCobotCppExample (here it is run in the build directory)
Run on Ubuntu20.04
Compile
- mkdir build && cd build
- cmake ..
- cmake --build .
Run
- Copy all .so files to the lib directory (note that you should unzip them after downloading. Do not unzip them in Windows and then copy them to Ubuntu. Unzip them directly in Ubuntu, such as: tar -xvf and then drag the files directly to the terminal)
- Soft link libQt5SerialPort.so.5 (in the QT installation directory, such as: /home/"username"/Qt5.12.10/5.12.10/gcc_64/lib) to mycobotcpp/build/bin (do not copy directly). The command is as follows (note that you should choose your path): ln -s /home/"Username"/Qt5.12.10/5.12.10/gcc_64/lib/libQt5SerialPort.so.5 /home/"Username"/myCobotCpp/build/bin/libQt5SerialPort.so.5
Common Problems and Solutions
Error during compilation:
Cannot find QTDIR. Solution: Check whether QTDIR is configured correctly, you can check it in the command line output: echo $QTDIRError during runtime:
Serial port problem: Cannot open the serial port. Solution: Modify the serial port permissions of the robot arm, you cannot directly chmod..., so you have to re-set the permissions every time you restart. Modify the file directly:cd /etc/udev/rules.d
- sudo gedit 20-usb-serial.rules
- Add to the file: KERNEL=="ttyUSB*" MODE="0777"
- File not found problem: such as being unable to open or find libQt5SerialPort.so.5. Solution: Check the above step 2
Note
If you do not use cmake to compile, such as using it directly in MFC, configure it as shown below: