I'm using LibTiff v4.0.3.
I had it working perfectly in multibyte, but when i try to work with Unicode, I get a runtime exception.
I can render the problem down to a single line:
#include "tiffio.h"
int _tmain(int argc, _TCHAR* argv[])
{
TIFF* tif = TIFFOpenW(L"D:\\Myfile", "r");
}
And this will work perfectly: TIFF* tif = TIFFOpen("D:\\Myfile", "r");
I can't get the exact exception code, but the code stack looks like this:
msvcr110.dll!__crt_debugger_hook(int _Reserved) Line 60 C
msvcr110.dll!_call_reportfault(int nDbgHookCode, unsigned long dwExceptionCode, unsigned long dwExceptionFlags) Line 155 C++
msvcr110.dll!_invoke_watson(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) Line 139 C++
msvcr110.dll!_invalid_parameter(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) Line 85 C++
msvcr110.dll!_invalid_parameter_noinfo() Line 97 C++
msvcr110.dll!_read(int fh, void * buf, unsigned int cnt) Line 84 C
ConsoleApplication1.exe!TIFFFdOpen() C
ConsoleApplication1.exe!TIFFClientOpen() C
ConsoleApplication1.exe!TIFFFdOpen() C
ConsoleApplication1.exe!TIFFOpenW() C
ConsoleApplication1.exe!wmain(int argc, wchar_t * * argv) Line 21 C++
ConsoleApplication1.exe!__tmainCRTStartup() Line 533 C
ConsoleApplication1.exe!wmainCRTStartup() Line 377 C
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown
I've tried using @err
and @err,hr
, but they show that there was no error.
How can I get the Unicode version to work ? Do I need to compile the library differently?
(I've checked and there's no check for the preprocessor variable UNICODE
in libtiff....)
Turns out you need to compile the library a bit differently when linking to debug mode project in Unicode.
Go to your libtiff folder, and open nmake.opt for editing.
Change the compilation flags to use debug CRT dlls (/MDd):
instead of just /MD
Now rebuild the library.
or for x64:
Make sure your project links to that file when you're in the debug configuration