I want to compile C++ program without “CMakeList.txt” compiling method as below guide.
(Installing C++ Distributions of PyTorch — PyTorch master documentation)
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch ..
cmake --build . --config Release
Is there anyway to write Makefile to compile below simple code?
//torch_test.cpp
#include<torch/torch.h>
#include<torch/script.h>
#include<iostream>
int main()
{
std:: cout << "Torch header successfully called" << std::endl;
return 0;
}
I’ve tried all the way when I compile using gcc above code. But I got this error message in Ubuntu.
gcc -I<libtorch path> torch_test.cpp
torch_test.cpp:1:10: fatal error: torch/torch.h: No such file or directory
#include <torch/torch.h>
^~~~~~~~~~~~~~~
compilation terminated.
Any ideas?