# URTool to Support c++11

**URL:** <https://forum.universal-robots.com/t/urtool-to-support-c-11/3520>\
**Category:** SDK and API\
**Created:** [January 25, 2019, 10:55pm UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520 "2019-01-25T22:55:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocohen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ocohen/32/2067_2.png) [@ocohen](https://forum.universal-robots.com/u/ocohen)\
**Post date:** [January 25, 2019, 10:55pm UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/1 "2019-01-25T22:55:49Z")

</div>

Is there a plan to create a new tool chain to support c++11?  
Current cpp compiler in URTool3 is very old.

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [January 29, 2019, 8:32am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/2 "2019-01-29T08:32:08Z")

</div>

Topic moved to Feature Requests.

---

<div class="post-metadata">

**Author:** ![mohamedghita](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mohamedghita](https://forum.universal-robots.com/u/mohamedghita)\
**Post date:** [February 7, 2019, 8:27am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/3 "2019-02-07T08:27:41Z")

</div>

@ocohen For now, you can simply ship the right libstdc++ with your URCap and edit the c++ app RPATH or LD\_LIBRARY\_PATH in a bash file that calls your c++ app.

---

<div class="post-metadata">

**Author:** ![anon14624655](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@anon14624655](https://forum.universal-robots.com/u/anon14624655)\
**Post date:** [July 9, 2019, 9:41am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/4 "2019-07-09T09:41:20Z")

</div>

@mohamedghita if I link it manually I get:

```
libstdc++.so: undefined reference to '_Unwind_GetIPInfo@GCC_4.2.0'

```

Do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![anon62734967](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon62734967](https://forum.universal-robots.com/u/anon62734967)\
**Post date:** [September 3, 2019, 10:41am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/5 "2019-09-03T10:41:10Z")

</div>

Hi,  
Is there any progress in this topic? Anyone who managed to compile and run c++11 code on the robot, feel free to share the instruction steps here 🙂

---

<div class="post-metadata">

**Author:** ![anon14624655](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@anon14624655](https://forum.universal-robots.com/u/anon14624655)\
**Post date:** [September 3, 2019, 12:26pm UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/6 "2019-09-03T12:26:07Z")

</div>

We’ve managed to build our c++11/14 daemon through static linking.  
Something like the following `CMakeLists.txt` example:

```
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
project(example_cpp14 VERSION 0.0.1 LANGUAGES CXX)

include_directories(include
  lib/include
  ...
)

add_executable(${PROJECT_NAME}
  src/main_cpp14.cpp
  lib/src/lib_cpp14.cpp
  ...
)

target_link_libraries(${PROJECT_NAME}
  PUBLIC
    # the following library list order is crucial!
    xmlrpc_server_abyss++
    xmlrpc_server_abyss
    xmlrpc_server_pstream++
    xmlrpc_server
    xmlrpc_abyss
    xmlrpc_server++
    xmlrpc++
    xmlrpc
    xmlrpc_packetsocket
    xmlrpc_xmlparse
    xmlrpc_xmltok
    xmlrpc_util
    curl
    pthread
)

set_target_properties(${PROJECT_NAME}
  PROPERTIES
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED ON
    COMPILE_FLAGS "-m32 -march=i686"
    LINK_FLAGS "-m32 -static-libstdc++ -static-libgcc -static"
)

install(
  TARGETS ${PROJECT_NAME}
  RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/../src/main/resources/com/example_company/example_urcap_cpp14/impl/daemon
)

```

Of course you need all the 32-bit static librariy files, i.e. `*.a` libraries to successfully compile through `cmake`.

---

<div class="post-metadata">

**Author:** ![anon44414354](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon44414354](https://forum.universal-robots.com/u/anon44414354)\
**Post date:** [February 14, 2020, 8:20am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/7 "2020-02-14T08:20:51Z")

</div>

Hi Alessandro

Just following up on your post about the compilation of your code supporting c++11, because I am not sure I understand everything.

According to your post, you’re using cmake. Are you still using the compilers coming with urtool? Are you not using scons anymore in your process?  
Would it mean then that in your compilation process, you are first compiling your daemon with cmake and then compiling your urcap with maven?

Thank you in advance for answers.

---

<div class="post-metadata">

**Author:** ![anon14624655](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@anon14624655](https://forum.universal-robots.com/u/anon14624655)\
**Post date:** [February 14, 2020, 12:02pm UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/8 "2020-02-14T12:02:50Z")

</div>

Hello Francois,

I’m using an external `cmake` project which is compiled through the default linux compiler (e.g. gcc version 8.3.0 in my case).  
I’m not using `scons` any longer, but I have not automated the compilation process inside maven yet.  
So I build the daemon executable externally, and thanks to the `install` macro I get the same behavior of the scons compilation (in terms of output location of the executable). Be aware that you will need to call the install macro manually to make it works.  
And as you have imagined I later build the URCap with maven (without the `scons` instructions), and I can avoid recompiling the `cmake` project from now on if I don’t make any changes there.

Enjoy

---

<div class="post-metadata">

**Author:** ![anon44414354](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon44414354](https://forum.universal-robots.com/u/anon44414354)\
**Post date:** [February 16, 2020, 9:06am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/9 "2020-02-16T09:06:46Z")

</div>

Hello Alessandro

Thank you very much for your explanations! I’ll give it a try.

---

<div class="post-metadata">

**Author:** ![anon44414354](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon44414354](https://forum.universal-robots.com/u/anon44414354)\
**Post date:** [March 6, 2020, 1:03pm UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/10 "2020-03-06T13:03:40Z")

</div>

Hi Alessandro, hi all,

So I tried as far as I could to build a c++11/14 daemon through static linking but I am stuck now and I don’t know how to go on.

I followed Alessandro’s guidances as most as possible:

- I am working with the latest URCap Starter Package with sdk 1.9.0. The native gcc compiler version here is 5.4.0. My daemon just implements an empty main function returning 0 without including anything for now.

- I downloaded the latest gcc source code and after some time managed to build the 32 bit static libraries to link the daemon to, thanks to the native compiler of the URCap Starter Package. I ran the “make install” command into a dedicated folder that I copied within my daemon data structure.  
– So, first question here, is that the right way to do so? Obviously not exactly as I am not managing to make my daemon work for now.  
– Alessandro is working with gcc version 8.3.0. Should I thus update my native compiler to build the gcc source code and to run cmake with to build the daemon afterwards? Or should I just replace the native compiler of the URCap Starter package with the gcc version I am building and work with it from now on?

- I wrote then my CMakeLists.txt such as:

> cmake\_minimum\_required(VERSION 3.0.2 FATAL\_ERROR)
> 
> project(HelloWorld VERSION 0.0.1 LANGUAGES CXX)
> 
> include\_directories(  
> .  
> ./link\_to\_headers\_of\_gcc  
> )
> 
> link\_directories(  
> ./link\_to\_32\_bit\_static\_libs\_of\_gcc  
> )
> 
> add\_executable(${PROJECT\_NAME}  
> HelloWorld.cpp  
> )
> 
> set\_target\_properties(${PROJECT\_NAME}  
> PROPERTIES  
> CXX\_STANDARD 14  
> CXX\_STANDARD\_REQUIRED ON  
> COMPILE\_FLAGS “-m32 -march=i686”  
> LINK\_FLAGS “-m32 -static-libstdc++ -static-libgcc -static”  
> )

Doing such, I can compile and run the “empty” daemon. But as soon as I am including in my code _iostream_ for instance, I am fighting with include errors, iostream including files that include files… I tried to add in the CMakeLists.txt file more include paths from my new gcc install folder but I am then getting this kind of errors when compiling, which makes me stop trying:

> error: there are no arguments to ‘\_\_is\_constructible’ that depend on a template parameter, so a declaration of ‘\_\_is\_constructible’ must be available [-fpermissive]  
> : public \_\_bool\_constant\<\_\_is\_constructible(\_Tp, \_Args…)\>

or

> error: ‘\_\_builtin\_addressof’ was not declared in this scope

Looking at the net, I have the feelings that these errors are due to multiple gcc version conflicts. I did not manage to solve them, one error bringing the other one.  
– I am basically stuck here and don’t manage to move forward. What can I do to make it work?

- Let’s imagine now that I can run c++11 compliant code now. I need thus afterwards to add in my CMakeLists.txt file the following:

> target\_link\_libraries(${PROJECT\_NAME}  
> PUBLIC  
> xmlrpc\_server\_abyss++  
> xmlrpc\_server\_abyss  
> xmlrpc\_server\_pstream++  
> xmlrpc\_server  
> xmlrpc\_abyss  
> xmlrpc\_server++  
> xmlrpc++  
> xmlrpc  
> xmlrpc\_packetsocket  
> xmlrpc\_xmlparse  
> xmlrpc\_xmltok  
> xmlrpc\_util  
> curl  
> pthread  
> )

I copied these libraries from the “urtool” framework installed in the URCap Starter Package into a dedicated folder located alongside my daemon. My CMakeLists.txt file looks now like that:

> cmake\_minimum\_required(VERSION 3.0.2 FATAL\_ERROR)
> 
> project(HelloWorld VERSION 0.0.1 LANGUAGES CXX)
> 
> include\_directories(  
> .  
> ./link\_to\_headers\_of\_gcc  
> ./link\_to\_headers\_of\_urtool  
> )
> 
> link\_directories(  
> ./link\_to\_32\_bit\_static\_libs\_of\_gcc  
> ./link\_to\_libs\_of\_urtool  
> )
> 
> add\_executable(${PROJECT\_NAME}  
> HelloWorld.cpp  
> )
> 
> target\_link\_libraries(${PROJECT\_NAME}  
> PUBLIC  
> xmlrpc\_server\_abyss++  
> xmlrpc\_server\_abyss  
> xmlrpc\_server\_pstream++  
> xmlrpc\_server  
> xmlrpc\_abyss  
> xmlrpc\_server++  
> xmlrpc++  
> xmlrpc  
> xmlrpc\_packetsocket  
> xmlrpc\_xmlparse  
> xmlrpc\_xmltok  
> xmlrpc\_util  
> curl  
> pthread  
> )
> 
> set\_target\_properties(${PROJECT\_NAME}  
> PROPERTIES  
> CXX\_STANDARD 14  
> CXX\_STANDARD\_REQUIRED ON  
> COMPILE\_FLAGS “-m32 -march=i686”  
> LINK\_FLAGS “-m32 -static-libstdc++ -static-libgcc -static”  
> )

– It looks like that it is working (without the static linking of the 32 bit gcc libraries). But is that the best way to do it?

Thanks in advance for your answers.

---

<div class="post-metadata">

**Author:** ![s\_c](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@s\_c](https://forum.universal-robots.com/u/s_c)\
**Post date:** [September 8, 2020, 10:57am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/11 "2020-09-08T10:57:42Z")

</div>

Hi everyone,  
I’m trying the solution describe in this topic, but I get this error:

`AbyssServer.cpp:(.text+0xa9): undefined reference to `xmlrpc\_c::registry::…`

in `add_executable` I added all the src in the daemon example, including `AbyssServer.cpp` and ` XMLRPCMethods.cpp`

Could you help me?

---

<div class="post-metadata">

**Author:** ![anon62734967](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon62734967](https://forum.universal-robots.com/u/anon62734967)\
**Post date:** [September 11, 2020, 11:48am UTC](https://forum.universal-robots.com/t/urtool-to-support-c-11/3520/12 "2020-09-11T11:48:30Z")

</div>

Hi All,

We were able to build C++11 code on a regular **32-bit** ubuntu 18.04 LTS virtual machine (not used the UR cross-compiler or any libraries provided by that package) and then included the dependent system libraries in the same folder where the daemon is located.  
We did not use any static linking; instead we used a shell script to start the daemon with the correct LD\_LIBRARY\_PATH environment variable in order to find the required dependencies.

To find the dependencies, we used the ldd command on the compiler machine (ubuntu 18.04):

`ldd MyDaemon`

To run the daemon, we used the following shell script (in the same folder where the daemon is located):

```
#!/bin/bash
trap 'kill -TERM $PID' TERM INT
LD_LIBRARY_PATH=`pwd` `pwd`/MyDaemon &
PID=$!
wait $PID
trap - TERM INT
wait $PID
EXIT_STATUS=$?

```

Instead of starting the daemon executable directly, we start the shell script.

I hope this helps.
