Project

Profile

Help

testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll"

Added by Martin Honnen almost 5 years ago

I am trying to use SaxonHEC1.1.2 on Windows 10 with VS 2017, I installed it into the default location C:\Program Files\Saxonica\SaxonHEC1.1.2 and I am able to use the bat file buildCPPSaxonHE.bat to compile the samples from the samples\cppTests directory in a command line window of the developer command prompt of VS 2017.

However, when trying to run any of the tests e.g. testXQuery.exe I only get an error that the libsaxonhec.dll is not being found:

C:\Program Files\Saxonica\SaxonHEC1.1.2\samples\cppTests>.\testXQuery.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll
Error: : No error

A test dir "C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" however shows the file is there.

Any ideas what could be wrong?


Replies (21)

Please register to reply

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Hi Martin,

I have managed to reproduce the error message. It's strange not sure what has changed. Maybe what was released is different to the code in subversion. Investigating it now.

Thanks for reporting it.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Update:

After investigating this problem for a few hours something seems to have changed in a Windows update which is causing Excelsior Jet to fail. I have reported the issue to Excelsior Jet.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Update:

Not yet got to the bottom of the cause. The Excelsior Jet sample is working fine.

The Saxon/C DLL loads fine. But fails further down in the initDefaultJavaRT function, which is in the SaxonCGlue.c file.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

Thanks, I will try that today.

Looking at https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.API/HEC/SaxonCGlue.c I wonder whether

snprintf(resources_dir, rDir_len + 42 + 1,  "C:\\Program Files\\Saxonica\\SaxonHEC1.1.0", tempResources_dir);

should say

snprintf(resources_dir, rDir_len + 42 + 1,  "C:\\Program Files\\Saxonica\\SaxonHEC1.2.0", tempResources_dir);

Or is the 1.2.0 release using resources from the 1.1.0 release?

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

I am still getting the error, only it appears to be hit a bit later, now the output of testXPath.exe says

Test: XPathProcessor11

Test: SaxonProcessor  cp1
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll
Error: : No error

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Hi Martin,

I am not able to reproduce the error you are getting. So maybe there is some other difference with the files you have locally. I am in the process of doing a maintenance release for Saxon/C on Windows. So hopefully you can try the new download soon.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Hi,

I reproduced the error on Saxon-HE/C. Saxon-EE/C seems to be working fine on windows with the update.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

Unfortunately at least on the one machine I have tried it I get the same error as before

C:\Program Files\Saxonica\SaxonHEC1.1.3>.\samples\cppTests\testXSLT.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll
Error: : No error
C:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXPath.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll
Error: : No error

What did you identify as the problem, was that some change in the code or a change in the installation process?

I have no idea what to change, the documentation mentions some environment variable SAXONC_HOME, do I need to set that or should the installer set that or should the C++ code be able to find the library if the installer installed the program into the default directory C:\Program Files\Saxonica\SaxonHEC1.1.3?

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

I have now tried to install the HEC 1.1.3 release on another machine but I run into the same problem as before, I can run the bat file in the C++ samples directory to compile the testX sample programs just fine but on trying to run them they do nothing but complain about not being able to load the library "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll".

Here is the copy of the build and run tests in a Visual Studio 2017 developer command prompt:

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\buildCPPSaxonHE.bat

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>set jdkdir=C:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>cl /EHsc "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni" "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni\win32"  testXPath.cpp ../../Saxon.C.API/SaxonCGlue.c ../../Saxon.C.API/SaxonCXPath.c ../../Saxon.C.API/SaxonProcessor.cpp ../../Saxon.C.API/XdmValue.cpp ../../Saxon.C.API/XdmItem.cpp ../../Saxon.C.API/XdmAtomicValue.cpp ../../Saxon.C.API/XdmNode.cpp ../../Saxon.C.API/XQueryProcessor.cpp ../../Saxon.C.API/XSLTProcessor.cpp ../../Saxon.C.API/XPathProcessor.cpp ../../Saxon.C.API/SchemaValidator.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27030.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

testXPath.cpp
Generating Code...
Compiling...
SaxonCGlue.c
SaxonCXPath.c
Generating Code...
Compiling...
SaxonProcessor.cpp
XdmValue.cpp
XdmItem.cpp
XdmAtomicValue.cpp
XdmNode.cpp
XQueryProcessor.cpp
XSLTProcessor.cpp
XPathProcessor.cpp
SchemaValidator.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 14.16.27030.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:testXPath.exe
testXPath.obj
SaxonCGlue.obj
SaxonCXPath.obj
SaxonProcessor.obj
XdmValue.obj
XdmItem.obj
XdmAtomicValue.obj
XdmNode.obj
XQueryProcessor.obj
XSLTProcessor.obj
XPathProcessor.obj
SchemaValidator.obj

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>cl /EHsc "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni" "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni\win32"  testXSLT.cpp ../../Saxon.C.API/SaxonCGlue.c ../../Saxon.C.API/SaxonCXPath.c ../../Saxon.C.API/SaxonProcessor.cpp ../../Saxon.C.API/XdmValue.cpp ../../Saxon.C.API/XdmItem.cpp ../../Saxon.C.API/XdmAtomicValue.cpp ../../Saxon.C.API/XdmNode.cpp ../../Saxon.C.API/XQueryProcessor.cpp ../../Saxon.C.API/XSLTProcessor.cpp ../../Saxon.C.API/XPathProcessor.cpp ../../Saxon.C.API/SchemaValidator.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27030.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

testXSLT.cpp
Generating Code...
Compiling...
SaxonCGlue.c
SaxonCXPath.c
Generating Code...
Compiling...
SaxonProcessor.cpp
XdmValue.cpp
XdmItem.cpp
XdmAtomicValue.cpp
XdmNode.cpp
XQueryProcessor.cpp
XSLTProcessor.cpp
XPathProcessor.cpp
SchemaValidator.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 14.16.27030.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:testXSLT.exe
testXSLT.obj
SaxonCGlue.obj
SaxonCXPath.obj
SaxonProcessor.obj
XdmValue.obj
XdmItem.obj
XdmAtomicValue.obj
XdmNode.obj
XQueryProcessor.obj
XSLTProcessor.obj
XPathProcessor.obj
SchemaValidator.obj

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>cl /EHsc "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni" "-IC:\Program Files\Saxonica\SaxonHEC1.1.3\Saxon.C.API\jni\win32"  testXQuery.cpp ../../Saxon.C.API/SaxonCGlue.c ../../Saxon.C.API/SaxonCXPath.c ../../Saxon.C.API/SaxonProcessor.cpp ../../Saxon.C.API/XdmValue.cpp ../../Saxon.C.API/XdmItem.cpp ../../Saxon.C.API/XdmAtomicValue.cpp ../../Saxon.C.API/XdmNode.cpp ../../Saxon.C.API/XQueryProcessor.cpp ../../Saxon.C.API/XSLTProcessor.cpp ../../Saxon.C.API/XPathProcessor.cpp ../../Saxon.C.API/SchemaValidator.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27030.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

testXQuery.cpp
Generating Code...
Compiling...
SaxonCGlue.c
SaxonCXPath.c
Generating Code...
Compiling...
SaxonProcessor.cpp
XdmValue.cpp
XdmItem.cpp
XdmAtomicValue.cpp
XdmNode.cpp
XQueryProcessor.cpp
XSLTProcessor.cpp
XPathProcessor.cpp
SchemaValidator.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 14.16.27030.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:testXQuery.exe
testXQuery.obj
SaxonCGlue.obj
SaxonCXPath.obj
SaxonProcessor.obj
XdmValue.obj
XdmItem.obj
XdmAtomicValue.obj
XdmNode.obj
XQueryProcessor.obj
XSLTProcessor.obj
XPathProcessor.obj
SchemaValidator.obj
c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXPath.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll
Error: : No error

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>testXPath.exe

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXQuery.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll
Error: : No error

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>testXSLT.exe
Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll
Error: : No error

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXSLT.exe

c:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>

I don't have any idea whether that is an installation problem or compilation problem or some problem with the Saxon code or its library.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

It seems I have found the problem, it looks like the default developer command prompt is set up to compile for 32 bit while there is a different command prompt x64 native tools and after using that to run the bat file the testXXX programs now run and output the test results.

One oddity remains: one some runs the programs start and "work" for a time and then exit without outputting anything. I will have to test that a bit more to see whether there is some pattern behind that.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Martin Honnen wrote:

It seems I have found the problem, it looks like the default developer command prompt is set up to compile for 32 bit while there is a different command prompt x64 native tools and after using that to run the bat file the testXXX programs now run and output the test results.

Yes that explains it. In the 1.1.2 release, we decided to only build Saxon/C for the 64-bit platforms. Is that a show stopper for you?

One oddity remains: one some runs the programs start and "work" for a time and then exit without outputting anything. I will have to test that a bit more to see whether there is some pattern behind that.

Yes I have experienced this happening. I have created a bug issue to keep track of this issue: #4195

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Is this bug issue reported in #4195 happening on a first run or some subsequent run of the executable? It is possible we have released resources on the JET VM.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

In the 1.1.2 release, we decided to only build Saxon/C for the 64-bit platforms. Is that a show stopper for you?

No, it was just quite a hurdle in the attempt to get anything to work but is is probably lack of my experience to use C++ compilers.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by Martin Honnen almost 5 years ago

O'Neil Delpratt wrote:

Is this bug issue reported in #4195 happening on a first run or some subsequent run of the executable? It is possible we have released resources on the JET VM.

I am still not sure, looking through the command line history I find adjacent attempts like

C:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>testXSLT.exe

C:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXSLT.exe

C:\Program Files\Saxonica\SaxonHEC1.1.3\samples\cppTests>.\testXSLT.exe
Test: XsltProcessor with Saxon version=Saxon/C 1.1.3 running with Saxon-HE 9.8.0.15J from Saxonica

so it failed to output anything two times and then on the third run it suddenly worked.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Update:

It seems like the samples are failing intermittently in SaxonCGlue.c when it calls the following:

HANDLE hDll = LoadLibrary(name);

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Cause of the problem: the use of snprintf seems leads to pointer issues when building the path with the Dll name.

Workaround:

In the function loadDefaultDll()

Change:

return loadDll(NULL);

to

return loadDll("C:\Program Files\Saxonica\SaxonHEC1.1.3\libsaxonhec.dll" ");

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Martin Honnen wrote:

One oddity remains: one some runs the programs start and "work" for a time and then exit without outputting anything. I will have to test that a bit more to see whether there is some pattern behind that.

I have now fixed this problem, related to bug issue #4195. I have committed the fix to subversion available for the next maintenance release.

RE: testXXX samples on Windows compile but on running give error "Unable to load C:\Program Files\Saxonica\SaxonHEC1.1.2\libsaxonhec.dll" - Added by O'Neil Delpratt almost 5 years ago

Martin Honnen wrote:

I have no idea what to change, the documentation mentions some environment variable SAXONC_HOME, do I need to set that or should the installer set that or should the C++ code be able to find the library if the installer installed the program into the default directory C:\Program Files\Saxonica\SaxonHEC1.1.3?

I thought I would comment on this question regarding the environment variable SAXONC_HOME. For users who wish to install Saxon/C in a different directory than the default you can set this variable so that Saxon can find the library and associated files such as the data files, license file if using Saxon-EE/C, Saxon-PE/C. It works in the same way as environment variable in the Java product.

In the command prompt you do the following or some other directory:

set SAXONC_HOME=C:\Program Files\Saxonica\SaxonHEC1.1.3

The environment variable can be set via the 'Windows settings'->System.

    (1-21/21)

    Please register to reply