Link libtorch with make instead of cmake

Hey guys!

For a project I am forced to link LibTorch with a Makefile, I can’t use cmake. Now looking into the LibTorch
folder I am a little dazzled by all the different things. Could somebody point me in the right direction on how to do this, i.e. which libraries do I have to link specifically?


You can do it, but you have to keep in mind that pytorch code changed very fast, symbols might changed their .so, for eg. we might want to split some of the .so to make the size of those .so smaller.
We do recommend to use cmake.

If you want to use make, check this post:
How do i to create a new project in C++ to run libtorch without cmake?
And I believe now you need to add -ltorch_python after -lc10 as well. And if your code has symbols in other .so, you should add them as well. All the .so are in the {your_libtorch_root|/lib, and if you get and missing symbol when linking, you can try finding the missing symbol within the .so in that folder and then add them into your make line.

1 Like

Thank you!

I looked at the g++ commands when running the Makefile that cmake produces and was able to glue together something that works.

I am all for using cmake, unfortunately we have a little transition time before we switch build systems completely. My team doesn‘t want to mix systems until then.