You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Graf László <gr...@datatrans.hu> on 2010/03/03 21:27:33 UTC

DSO problem

Hi all,

I test the DSO sample from http://dev.ariel-networks.com/ on Linux and  
it works fine. OK, now I would like to test my own little library.

Its header file, apr_dso_f.h contains this function:

    static int f10(int p1);

and its source file contains these lines:

    #include <apr_dso_f.h>
    static int f10(int p1)
    {
	return p1*10;
    }

It compiles fine with the following command:

c:\MinGW\bin\gcc.exe apr_dso_f.c
                      -I e:\src\c_cpp\apr_test
                      -shared
                      -o apr_dso_f.so

I added the folder containig the apr_dso_f.so file to the PATH  
variable so the following test program does not complain about anything:

    #include <stdio.h>
    #include <stdlib.h>
    #include <assert.h>
    #include <apr_general.h>
    #include <apr_dso.h>

    int main(int argc, const char *argv[])
    {
       apr_status_t rv;
       apr_pool_t *mp;
       const char fname[] = "apr_dso_f.so";
       apr_dso_handle_t *dso_h;

    /*typedef int (*f10_t)(int x);
    f10_t f10;*/

       apr_initialize();
       apr_pool_create(&mp, NULL);

       if ((rv = apr_dso_load(&dso_h, fname, mp)) != APR_SUCCESS) {
          goto error;
       }
    /*if ((rv = apr_dso_sym((apr_dso_handle_sym_t*)&f10, dso_h,  
"f10")) != APR_SUCCESS) {
       goto error;
    }
    printf("%d\n", f10(12));*/

       apr_dso_unload(dso_h);
       apr_pool_destroy(mp);
       apr_terminate();
       return 0;
    error:
    {
       char errbuf[256];
       apr_strerror(rv, errbuf, sizeof(errbuf));
       printf("error: %d, %s (%s)\n", rv, errbuf, fname);
       apr_dso_error(dso_h, errbuf, sizeof(errbuf));
       printf("dso-error: %d, %s (%s)\n", rv, errbuf, fname);
    }
       apr_terminate();
       return -1;
    }

After removing the comment, building it and running it, fails with the  
following messages:

error: 720127, The specified procedure could not be found.   (apr_dso_f.so)
dso-error: 720127, No error (apr_dso_f.so)

Can somebody help me?

Thank you,
grafl



Re: DSO problem

Posted by "William A. Rowe Jr." <wr...@apache.org>.
On 3/4/2010 5:34 AM, Graf Laszlo wrote:
> 
> Is there a way to "scan" the shared library for its types and functions
> without knowing what is in there?

Yes.  Your questions suggest that you should do a web search for a C development
or unix development FAQ (and specifically the unix platform you are on).  These
point out what many different tools will accomplish for you and some are written
to get you started.

Re: DSO problem

Posted by Graf Laszlo <gr...@datatrans.hu>.
Hi Rüdiger,

Yes, it works now.

Is there a way to "scan" the shared library for its types and functions
without knowing what is in there?

Thank you.

grafl

Idézet (Ruediger Pluem <rp...@apache.org>):

> On 03.03.2010 21:27, Graf László wrote:
>> Hi all,
>>
>> I test the DSO sample from http://dev.ariel-networks.com/ on Linux and
>> it works fine. OK, now I would like to test my own little library.
>>
>> Its header file, apr_dso_f.h contains this function:
>>
>>    static int f10(int p1);
>>
>> and its source file contains these lines:
>>
>>    #include <apr_dso_f.h>
>>    static int f10(int p1)
>
> This one is static so its symbol is not exported. Remove static and it should
> work fine.
>
> Regards
>
> Rüdiger
>




Re: DSO problem

Posted by Ruediger Pluem <rp...@apache.org>.
On 03.03.2010 21:27, Graf László wrote:
> Hi all,
> 
> I test the DSO sample from http://dev.ariel-networks.com/ on Linux and
> it works fine. OK, now I would like to test my own little library.
> 
> Its header file, apr_dso_f.h contains this function:
> 
>    static int f10(int p1);
> 
> and its source file contains these lines:
> 
>    #include <apr_dso_f.h>
>    static int f10(int p1)

This one is static so its symbol is not exported. Remove static and it should
work fine.

Regards

Rüdiger