[pjsip] Building pjsua as DLL

Roland Klabunde roland.klabunde at freenet.de
Fri Nov 16 03:20:28 EST 2007


Hello guys,

I've found a rather old recommendation from Benny in my notes about how to 
build a DLL, which I used a year ago or so in order to build DLLs:

<snip>


Next, you'd need to modify pjsua.h. Just below PJ_BEGIN_DECL line, add

this snippet:



#if defined(PJ_EXPORTING) && PJ_EXPORTING!=0

# undef PJ_DECL

# undef PJ_DEF

# define PJ_DECL(T)    __declspec(dllexport) T

# define PJ_DEF(T)    PJ_DECL(T)

#elif defined(PJ_IMPORTING) && PJ_IMPORTING!=0

# undef PJ_DECL

# undef PJ_DEF

# define PJ_DECL(T)    __declspec(dllimport) T

# define PJ_DEF(T)    PJ_DECL(T)

#endif



Next, add PJ_EXPORTING=1 macro in the DLL project settings.



Build the project, and you'll get the DLL.



I haven't tried loading the DLL myself, but if you have any problems,

then perhaps you need to implement DllMain() function.



cheers,

-benny





</snip>

Because I already handed over the project to a colleague, who reported 
problems to rebuild the DLLs using one of the latest SVN revs: Is the 
recommendation above still OK, or did it change? If yes, how is the way to 
build a DLL now?

Kind regards



----- Original Message ----- 
From: "Benny Prijono" <bennylp at pjsip.org>
To: "pjsip embedded/DSP SIP discussion" <pjsip at lists.pjsip.org>
Sent: Friday, November 16, 2007 4:51 AM
Subject: Re: [pjsip] Building pjsua as DLL



Thanks for testing it, Vali. I've committed the change in SVN.

cheers,
  -benny

Tomás Valenta wrote:
> Thank you, it does work! And it is smart. I could not find this because
> Intellisense keep telling me that the source is C++ (__cplusplus defined;
> I was playing only with this branch of macros) but it is compiled as ANSI 
> C.
> Strange.
> Cheers
>     Vali
>
>
> ----- Original Message ----- 
> From: "Benny Prijono" <bennylp at pjsip.org>
> To: "pjsip embedded/DSP SIP discussion" <pjsip at lists.pjsip.org>
> Sent: Wednesday, November 14, 2007 4:45 AM
> Subject: Re: [pjsip] Building pjsua as DLL
>
>
> Thanks for the info. Can I ask for a favor to try out these patch?
>
> What if instead of commenting out PJ_EXPORT_DEF_SPECIFIER, we change
> the PJ_DECL_NO_RETURN declaration in pj/config.h to something like this:
>
> #ifdef __cplusplus
> #  define PJ_DECL_NO_RETURN(type)   PJ_DECL(type) PJ_NORETURN
> #else
> #  define PJ_DECL_NO_RETURN(type)   PJ_NORETURN PJ_DECL(type)
> #endif
>
> Does this work for your DLL?
>
> If it does, I would prefer this approach since the empty
> PJ_EXPORT_DEF_SPECIFIER may not work for other platforms (such as
> Symbian, which IIRC expects the export specification in the
> definition rather than in declaration).
>
> cheers,
>   -benny



_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org





More information about the pjsip mailing list