title: C++ program using torch compiles, but cannot load libtorch.so at runtime
body: <p>I am using C++ code that integrates torch and runs lua scripts internally. I have compiled and installed torch and torch is running successfully. As such, the c++ project compiles and produces executables with no errors. </p>
  
  <p>At run time, the code receives lua script name as a parameter, and tries to execute this script. This lua script alone runs via torch, i.e. th script.lua runs and shows no errors. However within the code I get a runtime error: /home/jeffrey/torch/install/share/lua/5.1/torch/init.lua:13: cannot load '/home/jeffrey/torch/install/lib/lua/5.1/libtorch.so'. </p>
  
  <p>I have tried removing libtorch.so from the directory and then I get an error that the library cannot be found so the problem is that it cannot be loaded and I am not exactly sure what this means. I tried giving additional permissions to all the libraries in my torch installation as superuser - this did not work. </p>
  
  <p>I am running the executable as follows: </p>
  
  <p>../../train_obj -oscript train_obj.lua</p>
  
  <p>where train_obj is the executable and train_obj.lua is the script that is going to be run.
  In the script, there are require statements to include modules from torch. When "require" is called, init.lua is triggered.</p>
  
  <p>In init.lua on lines 12 and 13 the following require statements appear:</p>
  
  <p>(line 12) require "paths"</p>
  
  <p>(line 13) paths.require "libtorch"</p>
  
  <p>Line 13 apparently tries to load the libtorch library, i.e. libtorch.so.
  At this line, at run time, the above error occurs.</p>
  
  <p>I am having difficulty troubleshooting what to do to enable this library to load at runtime. Again - if I directly use torch via the th statement and call either:
  th train_obj.lua
  or:
  th init.lua
  everything is fine - both run without error.
  Only when I run train_obj.lua through the code, which causes init.lua to be run, do I get the error loading the library. 
  If anyone has experienced this and has understood what is needed to enable loading the library, I'd appreciate assistance with this issue.</p>