caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] FindLib loading dllunix.dll on vs2012
@ 2016-03-30 16:24 Pang, Wai (CA-CIB)
  2016-03-30 17:36 ` Fabrice Le Fessant
  2016-04-01  8:43 ` David Allsopp
  0 siblings, 2 replies; 5+ messages in thread
From: Pang, Wai (CA-CIB) @ 2016-03-30 16:24 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 4330 bytes --]

Has anyone tried compiling FindLib with the visual studio 2012 or later.

This is ok with visual studio 2008 and an old version of ocaml 3.11.
I have also tried the most recent release tar balls of ocaml and flex without any success.

FindLib package has a prebuild configuration to test loading dlls as:

ocaml unix.cma  - > fails with Reason: .\dllunix.dll: Invalid access to memory location.

(This command line routine has a dependency of ocamlrun.exe, pervasive.cma and dllunix.dll
which I have compiled all from src code using vs 2012. I have tried both static and dynamic linkage to no avail.)

This error originates from  flexdll.c in the FlexDLL package. It tries to call LoadLibraryEx and is returning null.

Further Testing

// A test to load dllunix dynamically ....
#include <flexdll.h>
#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[]) {
    void *handle;
    printf("Try open: %s\n", argv[1]);
    handle = flexdll_dlopen(argv[1], FLEXDLL_RTLD_GLOBAL);
    printf("Handle: %p\n", handle);
    if (handle == NULL) {
            printf("Error code: %d\n", GetLastError());
            printf("Error message: %s\n", flexdll_dlerror());
    }
    return 0;
}

cl -nologo -MD -I"D:\external\OCaml\FlexDLL_034" -c Testdll.c
flexlink -v -merge-manifest -exe -o testdll Testdll.obj

Direct test of dllunix.dll

$./testdll dllunix.dll

Try open:dllunix.dll
Error code: 998
Error message: Invalid access to memory location.

Instead of using dllunix.dll I have tried to compile a simple program for testing

A simplified test

#include <stdio.h>
int x = 10;
void dump_x(void) {
printf("myplugin finds the value : \nx=%i\n", x); fflush( stdout );
}

cl -nologo -MD  -I.. -c myplug.c
flexlink.exe -chain msvc -merge-manifest  -v -o myplug.dll  myplug.obj -link ws2_32.lib

$./testdll  myplug.dll

Try open: myplug.dll
Error code: 998
Error message: Invalid access to memory location.

Note that   the dump exe in flexdll fails in the same manner

In vs2008 build this is ok


$./testdll  myplug.dll

Try open: myplug.dll
Handle: 01F6DB78

Even running the test/dump.exe from flexDLL is ok

$ ./dump myplug.dll

INIT
Dynamic symbol at 00412000 (size = 12)
[0]  00402227: __iob_func
[1]  00401BA0: api
[2]  00402E7C: fflush
[3]  004017F0: flexdll_dlclose
[4]  004018B0: flexdll_dlerror
[5]  00401580: flexdll_dlopen
[6]  00401860: flexdll_dlsym
[7]  00401900: flexdll_dump_exports
[8]  00401A60: flexdll_dump_relocations
[9]  00401000: flexdll_relocate
[10]  00401BC0: main
[11]  00401D0E: printf
OK
** Loading myplug.dll
** handle = 01FEDB78
Dynamic symbol at 004C0000 (size = 4)
[0]  004B1000: FlexDLLiniter@12
[1]  004B1170: dump_x
[2]  004B11A0: torun
[3]  004BC014: x
myplugin finds the value :
x=10




This email does not create a legal relationship between any member of the Crédit Agricole group and the recipient or constitute investment advice. The content of this email (including any attachments) is intended solely for the addressee and access by any other person is not authorised. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient of this email, (i) you should send it back to us and delete it from your system, and (ii) you are prohibited from retaining, distributing, disclosing or using (in whole or part) any of its content. Email communication may be logged and archived, monitored and/or disclosed to third parties.

Crédit Agricole Corporate and Investment Bank is authorised by the Autorité de Contrôle Prudentiel et de Résolution (ACPR) and supervised by the ACPR and the Autorité des Marchés Financiers (AMF) in France and subject to limited regulation by the Financial Conduct Authority and the Prudential Regulation Authority. Details about the extent of our regulation by the Financial Conduct Authority and the Prudential Regulation Authority are available from us on request. Crédit Agricole Corporate and Investment Bank is incorporated in France with limited liability and registered in England and Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA
Please refer to http://www.ca-cib.com/group-overview/dodd-frank-otc-derivatives.htm for any Dodd-Frank Disclosure for U.S. Persons pursuant to CFTC Regulation 23.431

[-- Attachment #2: Type: text/html, Size: 13120 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] FindLib loading dllunix.dll on vs2012
  2016-03-30 16:24 [Caml-list] FindLib loading dllunix.dll on vs2012 Pang, Wai (CA-CIB)
@ 2016-03-30 17:36 ` Fabrice Le Fessant
  2016-03-31  8:03   ` Pang, Wai (CA-CIB)
  2016-04-01  8:43 ` David Allsopp
  1 sibling, 1 reply; 5+ messages in thread
From: Fabrice Le Fessant @ 2016-03-30 17:36 UTC (permalink / raw)
  To: Pang, Wai (CA-CIB), caml-list

[-- Attachment #1: Type: text/plain, Size: 5209 bytes --]

Have you tried to use ocpwin ?

--Fabrice

On Wed, Mar 30, 2016 at 6:25 PM Pang, Wai (CA-CIB) <Wai.Pang@ca-cib.com>
wrote:

> Has anyone tried compiling FindLib with the visual studio 2012 or later.
>
>
>
> This is ok with visual studio 2008 and an old version of ocaml 3.11.
>
> I have also tried the most recent release tar balls of ocaml and flex
> without any success.
>
>
>
> FindLib package has a prebuild configuration to test loading dlls as:
>
>
>
> *ocaml unix.cma*  - > fails with Reason: .\dllunix.dll: Invalid access to
> memory location.
>
>
>
> (This command line routine has a dependency of ocamlrun.exe, pervasive.cma
> and dllunix.dll
>
> which I have compiled all from src code using vs 2012. I have tried both
> static and dynamic linkage to no avail.)
>
>
>
> This error originates from  flexdll.c in the *FlexDLL* package. It tries
> to call LoadLibraryEx and is returning null.
>
>
>
> *Further Testing *
>
>
>
> // A test to load dllunix dynamically ….
>
> #include <flexdll.h>
>
> #include <stdio.h>
>
> #include <windows.h>
>
>
>
> int main(int argc, char *argv[]) {
>
>     void *handle;
>
>     printf("Try open: %s\n", argv[1]);
>
>     handle = flexdll_dlopen(argv[1], FLEXDLL_RTLD_GLOBAL);
>
>     printf("Handle: %p\n", handle);
>
>     if (handle == NULL) {
>
>             printf("Error code: %d\n", GetLastError());
>
>             printf("Error message: %s\n", flexdll_dlerror());
>
>     }
>
>     return 0;
>
> }
>
>
>
> *cl -nologo -MD -I"D:\external\OCaml\FlexDLL_034" -c Testdll.c*
>
> *flexlink -v -merge-manifest -exe -o testdll Testdll.obj*
>
>
>
> *Direct test of dllunix.dll*
>
>
>
> *$./testdll dllunix.dll*
>
>
>
> *Try open:dllunix.dll*
>
> *Error code: 998*
>
> *Error message: Invalid access to memory location.*
>
>
>
> Instead of using dllunix.dll I have tried to compile a simple program for
> testing
>
>
>
> *A simplified test*
>
>
>
> #include <stdio.h>
>
> int x = 10;
>
> void dump_x(void) {
>
> printf("myplugin finds the value : \nx=%i\n", x); fflush( stdout );
>
> }
>
>
>
> *cl -nologo -MD  -I.. -c myplug.c*
>
> *flexlink.exe -chain msvc -merge-manifest  -v -o myplug.dll  myplug.obj
> -link ws2_32.lib*
>
>
>
> *$./testdll  myplug.dll*
>
>
>
> *Try open: myplug.dll*
>
> *Error code: 998*
>
> *Error message: Invalid access to memory location.*
>
>
>
> Note that   the dump exe in flexdll fails in the same manner
>
>
>
> *In vs2008 build this is ok *
>
>
>
>
>
> *$./testdll  myplug.dll*
>
>
>
> Try open: myplug.dll
>
> Handle: 01F6DB78
>
>
>
> Even running the test/dump.exe from flexDLL is ok
>
>
>
> *$ ./dump myplug.dll *
>
>
>
> INIT
>
> Dynamic symbol at 00412000 (size = 12)
>
> [0]  00402227: __iob_func
>
> [1]  00401BA0: api
>
> [2]  00402E7C: fflush
>
> [3]  004017F0: flexdll_dlclose
>
> [4]  004018B0: flexdll_dlerror
>
> [5]  00401580: flexdll_dlopen
>
> [6]  00401860: flexdll_dlsym
>
> [7]  00401900: flexdll_dump_exports
>
> [8]  00401A60: flexdll_dump_relocations
>
> [9]  00401000: flexdll_relocate
>
> [10]  00401BC0: main
>
> [11]  00401D0E: printf
>
> OK
>
> ** Loading myplug.dll
>
> ** handle = 01FEDB78
>
> Dynamic symbol at 004C0000 (size = 4)
>
> [0]  004B1000: FlexDLLiniter@12
>
> [1]  004B1170: dump_x
>
> [2]  004B11A0: torun
>
> [3]  004BC014: x
>
> myplugin finds the value :
>
> x=10
>
>
>
>
>
>
>
>
>
> This email does not create a legal relationship between any member of the
> Crédit Agricole group and the recipient or constitute investment advice.
> The content of this email (including any attachments) is intended solely
> for the addressee and access by any other person is not authorised. It may
> contain information which is confidential, privileged or otherwise
> protected from disclosure. If you are not the intended recipient of this
> email, (i) you should send it back to us and delete it from your system,
> and (ii) you are prohibited from retaining, distributing, disclosing or
> using (in whole or part) any of its content. Email communication may be
> logged and archived, monitored and/or disclosed to third parties.
>
>
>
> Crédit Agricole Corporate and Investment Bank is authorised by the
> Autorité de Contrôle Prudentiel et de Résolution (ACPR) and supervised by
> the ACPR and the Autorité des Marchés Financiers (AMF) in France and
> subject to limited regulation by the Financial Conduct Authority and the
> Prudential Regulation Authority. Details about the extent of our regulation
> by the Financial Conduct Authority and the Prudential Regulation Authority
> are available from us on request. Crédit Agricole Corporate and
> Investment Bank is incorporated in France with limited liability and
> registered in England and Wales. Registration number: FC008194. Registered
> office: Broadwalk House, 5 Appold Street, London, EC2A 2DA
>
> Please refer to
> http://www.ca-cib.com/group-overview/dodd-frank-otc-derivatives.htm for
> any Dodd-Frank Disclosure for U.S. Persons pursuant to CFTC Regulation
> 23.431
>

[-- Attachment #2: Type: text/html, Size: 11319 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Caml-list] FindLib loading dllunix.dll on vs2012
  2016-03-30 17:36 ` Fabrice Le Fessant
@ 2016-03-31  8:03   ` Pang, Wai (CA-CIB)
  0 siblings, 0 replies; 5+ messages in thread
From: Pang, Wai (CA-CIB) @ 2016-03-31  8:03 UTC (permalink / raw)
  To: Fabrice Le Fessant, caml-list

[-- Attachment #1: Type: text/plain, Size: 1947 bytes --]

No. Unfortunately. I need ocaml libs using crt11 to link into our application.

I have just tried using the latest release tarball with flexdll_34 and the test programs works fine.
It might be possible that it has picked up an older version of flex in my previous test.

Let me rebuild dllunix.dll  with this new version of flexlink.

--Wai

This email does not create a legal relationship between any member of the Crédit Agricole group and the recipient or constitute investment advice. The content of this email (including any attachments) is intended solely for the addressee and access by any other person is not authorised. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient of this email, (i) you should send it back to us and delete it from your system, and (ii) you are prohibited from retaining, distributing, disclosing or using (in whole or part) any of its content. Email communication may be logged and archived, monitored and/or disclosed to third parties.

Crédit Agricole Corporate and Investment Bank is authorised by the Autorité de Contrôle Prudentiel et de Résolution (ACPR) and supervised by the ACPR and the Autorité des Marchés Financiers (AMF) in France and subject to limited regulation by the Financial Conduct Authority and the Prudential Regulation Authority. Details about the extent of our regulation by the Financial Conduct Authority and the Prudential Regulation Authority are available from us on request. Crédit Agricole Corporate and Investment Bank is incorporated in France with limited liability and registered in England and Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA
Please refer to http://www.ca-cib.com/group-overview/dodd-frank-otc-derivatives.htm for any Dodd-Frank Disclosure for U.S. Persons pursuant to CFTC Regulation 23.431

[-- Attachment #2: Type: text/html, Size: 6964 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Caml-list] FindLib loading dllunix.dll on vs2012
  2016-03-30 16:24 [Caml-list] FindLib loading dllunix.dll on vs2012 Pang, Wai (CA-CIB)
  2016-03-30 17:36 ` Fabrice Le Fessant
@ 2016-04-01  8:43 ` David Allsopp
  2016-04-01  9:30   ` Pang, Wai (CA-CIB)
  1 sibling, 1 reply; 5+ messages in thread
From: David Allsopp @ 2016-04-01  8:43 UTC (permalink / raw)
  To: Pang, Wai (CA-CIB), caml-list

[-- Attachment #1: Type: text/plain, Size: 5367 bytes --]

Are you using flexdll.obj and flexdll_initer.obj compiled using VS 2012 yourself from sources, or ones the FlexDLL binary distribution (which are not compiled with VS 2012)?

I did a lot of testing earlier this year in advance of 4.03 running the testsuite with every single version of Visual Studio (I went right back to Visual Studio 6), but I was always compiling the object files freshly for each compiler. Although I wasn’t building findlib, it would surprise me hugely that the testsuite would pass yet this systemically not work.

I’ve not used it, but I know that ocp-win includes the object files compiled for each version of Visual Studio, which is why Fabrice recommended it.


David

From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Behalf Of Pang, Wai (CA-CIB)
Sent: 30 March 2016 17:25
To: caml-list@inria.fr
Subject: [Caml-list] FindLib loading dllunix.dll on vs2012

Has anyone tried compiling FindLib with the visual studio 2012 or later.

This is ok with visual studio 2008 and an old version of ocaml 3.11.
I have also tried the most recent release tar balls of ocaml and flex without any success.

FindLib package has a prebuild configuration to test loading dlls as:

ocaml unix.cma  - > fails with Reason: .\dllunix.dll: Invalid access to memory location.

(This command line routine has a dependency of ocamlrun.exe, pervasive.cma and dllunix.dll
which I have compiled all from src code using vs 2012. I have tried both static and dynamic linkage to no avail.)

This error originates from  flexdll.c in the FlexDLL package. It tries to call LoadLibraryEx and is returning null.

Further Testing

// A test to load dllunix dynamically ….
#include <flexdll.h>
#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[]) {
    void *handle;
    printf("Try open: %s\n", argv[1]);
    handle = flexdll_dlopen(argv[1], FLEXDLL_RTLD_GLOBAL);
    printf("Handle: %p\n", handle);
    if (handle == NULL) {
            printf("Error code: %d\n", GetLastError());
            printf("Error message: %s\n", flexdll_dlerror());
    }
    return 0;
}

cl -nologo -MD -I"D:\external\OCaml\FlexDLL_034" -c Testdll.c
flexlink -v -merge-manifest -exe -o testdll Testdll.obj

Direct test of dllunix.dll

$./testdll dllunix.dll

Try open:dllunix.dll
Error code: 998
Error message: Invalid access to memory location.

Instead of using dllunix.dll I have tried to compile a simple program for testing

A simplified test

#include <stdio.h>
int x = 10;
void dump_x(void) {
printf("myplugin finds the value : \nx=%i\n", x); fflush( stdout );
}

cl -nologo -MD  -I.. -c myplug.c
flexlink.exe -chain msvc -merge-manifest  -v -o myplug.dll  myplug.obj -link ws2_32.lib

$./testdll  myplug.dll

Try open: myplug.dll
Error code: 998
Error message: Invalid access to memory location.

Note that   the dump exe in flexdll fails in the same manner

In vs2008 build this is ok


$./testdll  myplug.dll

Try open: myplug.dll
Handle: 01F6DB78

Even running the test/dump.exe from flexDLL is ok

$ ./dump myplug.dll

INIT
Dynamic symbol at 00412000 (size = 12)
[0]  00402227: __iob_func
[1]  00401BA0: api
[2]  00402E7C: fflush
[3]  004017F0: flexdll_dlclose
[4]  004018B0: flexdll_dlerror
[5]  00401580: flexdll_dlopen
[6]  00401860: flexdll_dlsym
[7]  00401900: flexdll_dump_exports
[8]  00401A60: flexdll_dump_relocations
[9]  00401000: flexdll_relocate
[10]  00401BC0: main
[11]  00401D0E: printf
OK
** Loading myplug.dll
** handle = 01FEDB78
Dynamic symbol at 004C0000 (size = 4)
[0]  004B1000: FlexDLLiniter@12
[1]  004B1170: dump_x
[2]  004B11A0: torun
[3]  004BC014: x
myplugin finds the value :
x=10




This email does not create a legal relationship between any member of the Crédit Agricole group and the recipient or constitute investment advice. The content of this email (including any attachments) is intended solely for the addressee and access by any other person is not authorised. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient of this email, (i) you should send it back to us and delete it from your system, and (ii) you are prohibited from retaining, distributing, disclosing or using (in whole or part) any of its content. Email communication may be logged and archived, monitored and/or disclosed to third parties.


Crédit Agricole Corporate and Investment Bank is authorised by the Autorité de Contrôle Prudentiel et de Résolution (ACPR) and supervised by the ACPR and the Autorité des Marchés Financiers (AMF) in France and subject to limited regulation by the Financial Conduct Authority and the Prudential Regulation Authority. Details about the extent of our regulation by the Financial Conduct Authority and the Prudential Regulation Authority are available from us on request. Crédit Agricole Corporate and Investment Bank is incorporated in France with limited liability and registered in England and Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA


Please refer to http://www.ca-cib.com/group-overview/dodd-frank-otc-derivatives.htm for any Dodd-Frank Disclosure for U.S. Persons pursuant to CFTC Regulation 23.431

[-- Attachment #2: Type: text/html, Size: 14715 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Caml-list] FindLib loading dllunix.dll on vs2012
  2016-04-01  8:43 ` David Allsopp
@ 2016-04-01  9:30   ` Pang, Wai (CA-CIB)
  0 siblings, 0 replies; 5+ messages in thread
From: Pang, Wai (CA-CIB) @ 2016-04-01  9:30 UTC (permalink / raw)
  To: David Allsopp, caml-list

[-- Attachment #1: Type: text/plain, Size: 2940 bytes --]

Thanks. I think I have this working now. I have been using consistent objs (MT|MD|CRT vers) and build everything from src.
The trick is to use a seed ocaml compiler (without flex).


1.       FlexDLL version 0.19 does not work with visual studio 12. The latest version 034 is ok.

2.       Avoid compiling FlexDLL with an ocaml compiler that is built with an older version of flexdll (hence the use of a seed compiler)

Regards

-Wai

From: David Allsopp [mailto:dra-news@metastack.com]
Sent: 01 April 2016 09:43
To: Pang, Wai (CA-CIB); caml-list@inria.fr
Subject: RE: [Caml-list] FindLib loading dllunix.dll on vs2012

Are you using flexdll.obj and flexdll_initer.obj compiled using VS 2012 yourself from sources, or ones the FlexDLL binary distribution (which are not compiled with VS 2012)?

I did a lot of testing earlier this year in advance of 4.03 running the testsuite with every single version of Visual Studio (I went right back to Visual Studio 6), but I was always compiling the object files freshly for each compiler. Although I wasn’t building findlib, it would surprise me hugely that the testsuite would pass yet this systemically not work.

I’ve not used it, but I know that ocp-win includes the object files compiled for each version of Visual Studio, which is why Fabrice recommended it.


David
This email does not create a legal relationship between any member of the Crédit Agricole group and the recipient or constitute investment advice. The content of this email (including any attachments) is intended solely for the addressee and access by any other person is not authorised. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient of this email, (i) you should send it back to us and delete it from your system, and (ii) you are prohibited from retaining, distributing, disclosing or using (in whole or part) any of its content. Email communication may be logged and archived, monitored and/or disclosed to third parties.

Crédit Agricole Corporate and Investment Bank is authorised by the Autorité de Contrôle Prudentiel et de Résolution (ACPR) and supervised by the ACPR and the Autorité des Marchés Financiers (AMF) in France and subject to limited regulation by the Financial Conduct Authority and the Prudential Regulation Authority. Details about the extent of our regulation by the Financial Conduct Authority and the Prudential Regulation Authority are available from us on request. Crédit Agricole Corporate and Investment Bank is incorporated in France with limited liability and registered in England and Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA
Please refer to http://www.ca-cib.com/group-overview/dodd-frank-otc-derivatives.htm for any Dodd-Frank Disclosure for U.S. Persons pursuant to CFTC Regulation 23.431

[-- Attachment #2: Type: text/html, Size: 11880 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-01  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30 16:24 [Caml-list] FindLib loading dllunix.dll on vs2012 Pang, Wai (CA-CIB)
2016-03-30 17:36 ` Fabrice Le Fessant
2016-03-31  8:03   ` Pang, Wai (CA-CIB)
2016-04-01  8:43 ` David Allsopp
2016-04-01  9:30   ` Pang, Wai (CA-CIB)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).