Dr. Stephen Henson wrote:
On Wed, Sep 15, 2004, Sravan wrote:

  
Hi,
I have been using X509 related functions in my code and for the 
definitions of functions like X509_free( ), I am using the macro 
IMPLEMENT_ASN1_FUNCTIONS(X509). In that macro expansion, 
ASN1_ITEM_rptr(X509) is used which expands to X509_it( ). I couldn't get 
the definition of this function anywhere and so the linker is reporting 
it as an unresloved symbol. Actually I couldn't understand the purpose 
of this ASN1_ITEM_rptr( ). Can anyone please explain me how to get 
around this?

I am using Openssl 0.9.7b in Windows platform.

    

What's the code that causes this error? There are some cases where you might
need to use ASN1_ITEM_rptr() directly but not many.
  
I need to use a function like X509_new( ) in my code.

The reason for that macro (and some related ones) is to do with certain
plaform quirks. In OpenSSL 0.9.7 and later ASN1 modules are defined in terms
of constant structures. 

When an external application ASN1 module needs to reference a module inside
OpenSSL itself it has to somehow determine a pointer to the relevant structure.

One some OSes you can't easily reference a pointer to a structure in a shared
library or (in the case of windows) you can't (or I couldn't) initialize a
structure at compile time to contain a pointer to a structure in a shared
library.

That is doing:

const SOME_STRUCT foo = {&bar,...};

where "bar" is in a shared library doesn't work.

The workaround for this is to export functions which return pointers
to the structures instead and include function pointers in the static
structure. The macros are there to allow applications to be
written which use the correct convention on all supported platforms.

  
Now I understood the use of ASN1_ITEM_rptr( ). Thank you.
But what if I dont wish to use the shared library(in which the functions that return pointers to structures are present)?
In my case, I need to use say a function like X509_free( ) with out linking libeay32.lib(in case of windows).
For that I use the macro IMPLEMENT_ASN1_FUNCTIONS(X509). But in that expansion, ASN1_ITEM_rptr(X509) will be used which is being replaced as X509_it( ) in my case. This is being reported as unresolved symbol by the linker.

Regards,
Sravan

Reply via email to