# XmlTree linker errors with Cinder-Warping on Linux

**URL:** <https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549>\
**Category:** Using Cinder\
**Created:** [February 6, 2017, 11:23am UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549 "2017-02-06T11:23:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [February 6, 2017, 11:23am UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549/1 "2017-02-06T11:23:59Z")

</div>

I’m trying to build Cinder-Warping on Linux with CMake. The CMakeLists.txt file:

> <https://github.com/gaborpapp/Cinder-Warping/blob/cmake/proj/cmake/cinder-warping-config.cmake>

which works fine in OS X, but in Linux is fails with a linker error related to `XmlTree`:

```auto
[100%] Linking CXX executable Debug/BasicWarping
libCinder-Warping.a(Warp.cpp.o): In function `ph::warping::Warp::toXml() const':
cinder/blocks/Cinder-Warping/src/Warp.cpp:151: undefined reference to `cinder::XmlTree::push_back(cinder::XmlTree const&)'
cinder/blocks/Cinder-Warping/src/Warp.cpp:165: undefined reference to `cinder::XmlTree::push_back(cinder::XmlTree const&)'
cinder/blocks/Cinder-Warping/src/Warp.cpp:172: undefined reference to `cinder::XmlTree::push_back(cinder::XmlTree const&)'
cinder/blocks/Cinder-Warping/src/Warp.cpp:179: undefined reference to `cinder::XmlTree::push_back(cinder::XmlTree const&)'
cinder/blocks/Cinder-Warping/src/Warp.cpp:181: undefined reference to `cinder::XmlTree::push_back(cinder::XmlTree const&)'
...

```

Although `libcinder.a` should contain the necessary symbols:

```auto
$ nm libcinder.a | grep XmlTree | grep push_back
0000000000003260 T _ZN6cinder7XmlTree9push_backERKS0_

```

I built the `FlickrTestMultithreaded` sample, which also uses `XmlTree`, but it compiles fine.

Do you have any idea what might be causing this? Any suggestions would be appreciated.

---

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [February 6, 2017, 4:32pm UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549/2 "2017-02-06T16:32:10Z")

</div>

Some more information:

Cinder is build with `-DCINDER_BOOST_USE_SYSTEM=1`, which implies `-D_GLIBCXX_USE_CXX11_ABI=1`

Tried with clang 3.8.1 and g++ 6.3.1.

Reduced the code to return only one error for this line in `Warp.cpp`, which is the only `setAttribute` call in the file:

```auto
xml.setAttribute( std::string, int );

```

These are the references in the object file, `Warp.cpp.o`, I’m not sure why there are two, maybe because of the templated fuction.

```auto
 U _ZN6cinder7XmlTree12setAttributeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_
 W _ZN6cinder7XmlTree12setAttributeIiEERS0_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_

```

This is the reference in libcinder:

```auto
T _ZN6cinder7XmlTree12setAttributeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_

```

I suspect this is an ABI error, but could not solve it so far.

---

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [February 6, 2017, 5:27pm UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549/3 "2017-02-06T17:27:14Z")

</div>

Turns out the issue was order dependent linking.  
It was solved by moving the following line in `cinderMakeApp.cmake` :

```auto
target_link_libraries( ${ARG_APP_NAME} cinder ${ARG_LIBRARIES} )

```

**after** the section where blocks are handled, like this:

```auto
foreach( block ${ARG_BLOCKS} )
...
endforeach()

target_link_libraries( ${ARG_APP_NAME} cinder ${ARG_LIBRARIES} )

```

I hope it helps someone in the future.

---

<div class="post-metadata">

**Author:** ![petros](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/petros/32/26_2.png) [@petros](https://discourse.libcinder.org/u/petros)\
**Post date:** [February 6, 2017, 9:50pm UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549/4 "2017-02-06T21:50:24Z")

</div>

Hi Gabor,

not entirely sure right now why your initial attempt works on OS X ( I would expect it not work as is the case on Linux ) but in any case the proper way to do it would be to privately link the block target with Cinder at the end of your block config. This would then allow the same config / block to be used in a CMake project that doesn’t use the `cinderMakeApp` macro to link with Cinder.

You can see how this looks [here](https://github.com/PetrosKataras/Cinder-NDI/blob/master/proj/cmake/Cinder-NDIConfig.cmake#L27-L33) . This should already fix the error you were getting but it might still be logical / cleaner ( in terms of linking order ) to also adopt the change you made in the macro upstream.

HTH,  
Petros

---

<div class="post-metadata">

**Author:** ![gabor\_papp](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gabor_papp/32/769_2.png) [@gabor\_papp](https://discourse.libcinder.org/u/gabor_papp)\
**Post date:** [February 7, 2017, 7:07am UTC](https://discourse.libcinder.org/t/xmltree-linker-errors-with-cinder-warping-on-linux/549/5 "2017-02-07T07:07:15Z")

</div>

Thanks Petros for a more proper way to solve this issue.
