Project

Profile

Help

Bug #4707

Library libsaxonhec.dll is not present in the system (Windows)

Added by O'Neil Delpratt 23 days ago. Updated 7 days ago.

Status:
In Progress
Priority:
Normal
Category:
Windows
Start date:
2020-09-02
Due date:
% Done:

0%

Estimated time:
Found in version:
1.2.1
Fixed in version:

Description

Reported by user:

When I create my new project I always got error message that library libsaxonhec.dll is not present in the system despite the path was correct and the library was in the appropriate directory.

Finally I found, that the problem is when compiling and define –DUNICODE is present. In this case this makes type mixture between const char* and const wchar_t* in macro LoadLibrary(…). Please see the file SaxonCGlue.c from line 137:

I have changed the code to (see below) and the problem disappeared (I’m running Win7 64bit and IDE is MS Visual Studio 2017):

#if !(defined (__linux__) || (defined (__APPLE__) && defined(__MACH__)))
#ifdef UNICODE
  wchar_t* wc = malloc(sizeof(wchar_t)*(strlen(name)+1));
  size_t convertedChars = 0;
  mbstowcs_s( &convertedChars, wc, strlen(name)+1, name, _TRUNCATE );
  HANDLE hDll = LoadLibraryW(wc); // Used for windows only
  free(wc);
#else
  HANDLE hDll = LoadLibraryA(name); // Used for windows only
#endif
#else
  HANDLE hDll = LoadLibraryA(name);
#endif

History

#1 Updated by O'Neil Delpratt 7 days ago

  • Status changed from New to In Progress

I have applied the suggested fix in the function loadDll of the SaxonGlue.h file. Change made in Saxon/C 1.2 and on the trunk.

Although it is not clear to me that the following part is in the second preprocessor else branch required changing from LoadLibrary(name) to LoadLibraryA(name) therefore I have only made the following change:

#if !(defined (__linux__) || (defined (__APPLE__) && defined(__MACH__)))
#ifdef UNICODE
  wchar_t* wc = malloc(sizeof(wchar_t)*(strlen(name)+1));
  size_t convertedChars = 0;
  mbstowcs_s( &convertedChars, wc, strlen(name)+1, name, _TRUNCATE );
  HANDLE hDll = LoadLibraryW(wc); // Used for windows only
  free(wc);
#else
  HANDLE hDll = LoadLibraryA(name); // Used for windows only
#endif
#else
        HANDLE hDll = LoadLibrary(name);
#endif

Testing required.

Please register to edit this issue

Also available in: Atom PDF