You can try one of the package mentioned in the FAQ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=docotherdirhttps://texfaq.org/FAQ-docotherdir.
But my advice is: Don't start pdflatex from another directory. Write your script or whatever you are doing to "automate" the generation of your docs so that it switches to the directory of the main file first. You obviously know the path from your current directory to the main file, so why don't you use it for a cd first?