Marco Marco - 1 month ago 19
C++ Question

use oracle oci.dll with mingw64 64bit compiler

I am trying to use the oracle oci library with the compiler mingw64.
If I link the oci.lib provided by oracle, my 64bit program crashes, because apparently mingw64 does not support linking with dll created with vc.

The workaround for this seems to be:

1) generate a def file from the oci.dll, which i am doing with mingw64 gendef (if I use this command "dlltool -z oci.def --export-all-symbol oci.dll" I get an empty def file, while if I use gendef I get a populated def file)

2) generate a import library oci.a with dlltool ("dlltool -d oci.def -l liboci.a")

however the oci.a library that I generate with dlltool is an empty file. In other works it seems that I am not able to generate this oci.a library, that I should use to link my program to the oci.dll

Does someone know how to solve this issue?
Is someone able to perform this task correctly?

Thank you

Marco

Answer

I've just generated liboci.a without any troubles. Probably you messed up something or used incorrect approach (dlltool -z ...). Here is how you do it:

  1. Download and install (can build from source) gendef utility:

  2. Run gendef oci.dll (will generate oci.def);

  3. Run dlltool -D oci.dll -d oci.def -l liboci.a (will generate liboci.a);

  4. Now try to link against liboci.a.

NOTE: Please, make sure that if your oci.dll is targeted at x86, then dlltool should be from the MinGW/MinGW-w64 distribution that is targeting x86 as well. The same goes for x64 case, i.e. it is important that targeted architectures match.