www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Help with the 'export' declaration and OpenSSL?

reply "Reid Levenick" <reid.levenick+dlang gmail.com> writes:
I'm trying to use the OpenSSL bindings from Deimos, but whenever 
I try to use the PEM_write_X509 function (among others), OpenSSL 
gives a fatal error of "no OPENSSL_Applink", because in OpenSSL's 
ms/uplink.c, the function OPENSSL_Uplink calls GetProcAddress on 
the application with the string "OPENSSL_Applink".

So far I've tried

Writing a D version of applink.c: I can't get dmd to export my 
OPENSSL_Applink without a leading underscore.
and
Recompiling OpenSSL without -DOPENSSL_ENABLE_APPLINK: Converting 
libraries to OMF gives me a series of errors in dmd that give the 
impression that the functions from io.h or a similar file are not 
visible. I can't get any compile to work.

 From what I can tell, there are two possible solutions to my 
problem:

Export OPENSSL_Applink from my D program without a leading 
underscore.
or
Get a working compile of OpenSSL and then add an underscore in 
uplink.c before recompiling.

If anybody could help me with either of these (or suggest a third 
option) that would be fantastic.
May 25 2013
parent "Reid Levenick" <reid.levenick+dlang gmail.com> writes:
On Sunday, 26 May 2013 at 00:38:23 UTC, Reid Levenick wrote:
 I'm trying to use the OpenSSL bindings from Deimos, but 
 whenever I try to use the PEM_write_X509 function (among 
 others), OpenSSL gives a fatal error of "no OPENSSL_Applink", 
 because in OpenSSL's ms/uplink.c, the function OPENSSL_Uplink 
 calls GetProcAddress on the application with the string 
 "OPENSSL_Applink".

 So far I've tried

 Writing a D version of applink.c: I can't get dmd to export my 
 OPENSSL_Applink without a leading underscore.
 and
 Recompiling OpenSSL without -DOPENSSL_ENABLE_APPLINK: 
 Converting libraries to OMF gives me a series of errors in dmd 
 that give the impression that the functions from io.h or a 
 similar file are not visible. I can't get any compile to work.

 From what I can tell, there are two possible solutions to my 
 problem:

 Export OPENSSL_Applink from my D program without a leading 
 underscore.
 or
 Get a working compile of OpenSSL and then add an underscore in 
 uplink.c before recompiling.

 If anybody could help me with either of these (or suggest a 
 third option) that would be fantastic.
For posterity: I got a compile of OpenSSL to work by configuring with "shared mingw", building, using dumpobj to get a list of exports from the dlls and making .defs for them, building a lib with the "lib" tool, and then converting that to OMF with coffimplib. There's definitely an easier way about this that I haven't found...
May 26 2013