By default, LibTIFF writes all error outputs to stderr. This seems to be hardcoded. Is there a way to redirect it to either a string message handler or a file? Ideally without modifying LibTIFF itself, but I'm okay with modifying if it is not too big of a change.

***Clarification #1***

I need to do this programmatically because I am using LibTIFF inside another library, and this library is not allowed to write anything to the stderr (otherwise it will mess up the application that uses my library). My library logs all errors to a file - I want LibTIFF errors to be redirected to this file as well.

I don't have control on the applications that use my library.

***Clarification #2***

My library is in C++ and runs on Windows.

If modification of LibTIFF is necessary, suggestions and advices are welcome.