Universal Robots+

Compile Daemon written in C from the URCap SDK

Hi all,
I want to use a Daemon in C language. I have made an executable in my urcaps. The deamon works OK on the ursim Virtual BOX, but the daemon is in Error on the real robot. I have tried to execute manually the daemon with Putty on the real robot, and I see that gcc is not installed : bash : gcc command not found.
It is impossible to compile and execute my code
Anyone has a idea to execute my Daemon ? I am surprised that my urcaps is OK on the URsim but not on the real robot…
I work with the SDK 1.9, UR Software 3.12.
Thanks,

Hi, have you used the cross compiler that is provided as a part of the URCaps SDK?
On the robot there is no gcc installed, you should use the cross compiler to build the executable in a virtual machine or docker.
If you think your binary is OK, try to start it manually from the Linux console and see that output it produces. Maybe you need some dependent libraries?

No, I used gcc on the virtual machine. How can I use this cross compiler ? What is it ?

Hi @abiard,

The cross compiler is an older version of gcc that generates executable for the specific Linux distribution running on the robot.
When you install the URCap SDK you are asked about installing it too. BUT the biggest disadvantage of the cross compiler is that you must have a 64 bit Linux to install it, otherwise it won’t be installed on any other system like Mac or Windows.
For this purpose we have created a Docker image with a 64 bit Linux base, but you can also use a virtual machine or install 64 bit Linux natively on an older PC just for building your code.

In general, you should not include any c/c++ code in the URCap, include only the executable that is created by the cross compiler.
See the “mydaemon” example in the SDK for further details where a “hello world” application is built and the executable is included in the URCap.

If your source code requires newer features of the c/c++ languages than the cross compiler can deal with, I suggest using a 32 bit Ubuntu 18.04 or its Docker equivalent, and build the executable there. In this case you need to find all the dependent system libraries by using the ldd command and include them in the same directory where your executable is located. However, this is very uncommon and very painful work - try to avoid it if you can.

The URSim simulator is not an exact simulation environment, you cannot use it for such compatibility testing, etc. Instead, you can download the exact robot image (i.e. binary copy of the SD card of the robot) and run it in a virtual machine. Using this techniquie we were able to identify compatibility issues with CB3.0 robots in our URCap.

I hope this will work for you

1 Like

Thanks for your reply
I don’t understand the command I should use to compile with the cross compiler ? gcc or other ?
What line of command must be written ?

Hi @abiard,

The short answer is /opt/urtool-3.0/bin/i686-unknown-linux-gnu-gcc

In more details, you won’t find one single executable that builds your program. There is a sample project in the SDK called “mydaemon” that you can try and see how the cross-compiler works. Use this sample code as a base for your project. The pom.xml file contains a section called “compile-daemon” that uses the scons build tool in the folder where the c/c++ project is located. Take a look at the configuration file “SConstruct” of the scons build tool in the daemon folder.

If the cross-compiler is successfully installed, you have the following environment variables defined: URTOOL_ROOT and URTOOL_TARGET:

ur@urdev:~$ echo $URTOOL_ROOT

/opt/urtool-3.0

ur@urdev:~$ echo $URTOOL_TARGET

i686-unknown-linux-gnu-

ur@urdev:~$

The SConstruct file creates a consistent build environment for compiling and linking with the right version of the system header files system libraries, that are also included in the /opt/urtool-3.0 folder.

ur@urdev:/opt/urtool-3.0$ ls -al bin
total 14400
drwxr-xr-x 2 root root 4096 okt. 31 2018 .
drwxr-xr-x 13 root root 4096 mars 2 2017 …
-rwxr-xr-x 1 root root 198404 juni 6 2016 curl
-rwxr-xr-x 1 root root 5073 juni 6 2016 curl-config
-rwxr-xr-x 1 root root 573920 juni 6 2016 i686-unknown-linux-gnu-addr2line
-rwxr-xr-x 1 root root 540928 juni 6 2016 i686-unknown-linux-gnu-ar
-rwxr-xr-x 1 root root 780256 juni 6 2016 i686-unknown-linux-gnu-as
-rwxr-xr-x 2 root root 132032 juni 6 2016 i686-unknown-linux-gnu-c++
-rwxr-xr-x 1 root root 570080 juni 6 2016 i686-unknown-linux-gnu-c++filt
-rwxr-xr-x 1 root root 130688 juni 6 2016 i686-unknown-linux-gnu-cpp
-rwxr-xr-x 2 root root 132032 juni 6 2016 i686-unknown-linux-gnu-g++
-rwxr-xr-x 2 root root 129504 juni 6 2016 i686-unknown-linux-gnu-gcc
-rwxr-xr-x 2 root root 129504 juni 6 2016 i686-unknown-linux-gnu-gcc-4.1.2
-rwxr-xr-x 1 root root 16233 juni 6 2016 i686-unknown-linux-gnu-gccbug
-rwxr-xr-x 1 root root 27360 juni 6 2016 i686-unknown-linux-gnu-gcov
-rwxr-xr-x 1 root root 2809256 juni 6 2016 i686-unknown-linux-gnu-gdb
-rwxr-xr-x 1 root root 2809256 juni 6 2016 i686-unknown-linux-gnu-gdbtui
-rwxr-xr-x 1 root root 849272 juni 6 2016 i686-unknown-linux-gnu-ld
-rwxr-xr-x 1 root root 583552 juni 6 2016 i686-unknown-linux-gnu-nm
-rwxr-xr-x 1 root root 737536 juni 6 2016 i686-unknown-linux-gnu-objcopy
-rwxr-xr-x 1 root root 822656 juni 6 2016 i686-unknown-linux-gnu-objdump
-rwxr-xr-x 1 root root 540928 juni 6 2016 i686-unknown-linux-gnu-ranlib
-rwxr-xr-x 1 root root 225280 juni 6 2016 i686-unknown-linux-gnu-readelf
-rwxr-xr-x 1 root root 516536 juni 6 2016 i686-unknown-linux-gnu-size
-rwxr-xr-x 1 root root 516568 juni 6 2016 i686-unknown-linux-gnu-strings
-rwxr-xr-x 1 root root 737536 juni 6 2016 i686-unknown-linux-gnu-strip
-rw-r–r-- 1 root root 1577 juni 6 2016 ptxconfig
-rwxr-xr-x 1 root root 5889 juni 6 2016 scons
-rwxr-xr-x 1 root root 5889 juni 6 2016 scons-1.2.0
-rwxr-xr-x 1 root root 16572 juni 6 2016 sconsign
-rwxr-xr-x 1 root root 16572 juni 6 2016 sconsign-1.2.0
-rwxr-xr-x 1 root root 48685 juni 6 2016 scons-time
-rwxr-xr-x 1 root root 48685 juni 6 2016 scons-time-1.2.0
-rwxr-xr-x 1 root root 6871 juni 6 2016 xmlrpc-c-config

If your cross-compiler is properly installed, you should have these files available in your computer.

Best regards,
Csaba