# Trouble with ROOT+libtorch make compilation

**URL:** <https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975>\
**Category:** Newbie\
**Tags:** build\
**Created:** [March 1, 2019, 1:32pm UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975 "2019-03-01T13:32:30Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [March 5, 2019, 9:49am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/21 "2019-03-05T09:49:54Z")

</div>

I see.  
You are getting an undefined reference to `RegisterModule`, which is contained in `libCore`, but `libCore` seems to be linked if I read the log correctly. I’m confused.

I can’t see obvious errors in your CMakeLists.

Also libtorch does not seem to be involved.

Can you compile a simple application that uses RDataFrame only via CMake?

---

<div class="post-metadata">

**Author:** ![amiucci](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@amiucci](https://root-forum.cern.ch/u/amiucci)\
**Post date:** [March 5, 2019, 9:55am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/22 "2019-03-05T09:55:14Z")

</div>

Hi,

I think it got lost in the discussion, taking out the Torch libraries there is no problem in having a cmake working, also with RDataFrame.  
So the answer is yes, I am able to compile with cmake applications with RDataFrame.

Antonello.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [March 5, 2019, 10:13am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/23 "2019-03-05T10:13:33Z")

</div>

It looks like your list in `ROOT_LIBRARIES` has no separator, so maybe the libraries are not actually being linked. Try using quoted and unquoted versions when linking, or separating the arguments by hand and checking if that solves your problem.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [March 5, 2019, 10:20am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/24 "2019-03-05T10:20:09Z")

</div>

But how could introducing libtorch into the build break the linking of ROOT libraries…? I’m lost 😅

---

<div class="post-metadata">

**Author:** ![Anthair](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Anthair](https://root-forum.cern.ch/u/Anthair)\
**Post date:** [March 5, 2019, 10:23am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/25 "2019-03-05T10:23:29Z")

</div>

Hi all, I rebuilt the setup provided by @amiucci in a separate environment and I have the exact same issues. Removing libtorch seems to fix the compilation problem.

---

<div class="post-metadata">

**Author:** ![amiucci](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@amiucci](https://root-forum.cern.ch/u/amiucci)\
**Post date:** [March 5, 2019, 10:26am UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/26 "2019-03-05T10:26:27Z")

</div>

My understanding is that by introducing the torch libraries the linking of ROOT got messed up, but I do not see really how and why by spying at the generated make command. I am lost in the comprehension of this and I was hoping to get some help exactly there.

By having a look into cmake guidelines it seems that target\_link\_libraries needs to handle the cross-dependancy, that you can find here: [https://cmake.org/cmake/help/v3.0/command/target\_link\_libraries.html](https://cmake.org/cmake/help/v3.0/command/target_link_libraries.html)

Now I do not see how this applies directly to this case, it would be interesting to understand if there is a piece of code in which ROOT is used together with other libraries in cmake, so that we can have a reference to look at and try to write our own application.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [March 5, 2019, 12:41pm UTC](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975/27 "2019-03-05T12:41:08Z")

</div>

Similar problem to using both `set(VAR ${VAR} ...)` and `list(APPEND VAR ...)` freely in CMake. Eventually CMake will mess up the `;` that separates the list and you’ll end up with one string with everything, or many broken strings that are not correct.

[Previous page](https://root-forum.cern.ch/t/trouble-with-root-libtorch-make-compilation/32975.md?page=1)
