Building with pjsua_lib as DLL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vali,

I found the dll files, turn out i set the output file to be dll and the name
to .exe, so i changed it to .dll and it's now there

my question now is, which functions i can PInvoke in the C# application? I
mean, in both pjsua and pjsua_lib projects, there's no function
with __declspec(dllexport) or anything, the only functions we put this
declaration for were in getopt.* in pjlib_util project which it's output is
a static library (.lib) file

am really confused right now so i'll really appreciate it if i could get
some help on how to use those dlls or how to import them in the C#
application or how to make my own

on another approach, i tried to recompile the dll made in Sipek project
(pjsipDll_mobile.dll). although the file works perfectly but there some
modifications i liked to do to it, so i recompiled it and remade it. strange
thing is the file size jumped from 700 KB to 1.1 MB, also, withough adding a
single line of code to it, it always gives me error "Can't find PInvoke DLL
'pjsipDll_mobile.dll'", do you have any idea why it does so?

On Mon, Jan 17, 2011 at 4:15 PM, Hesham Abboud <hesham.abboud at gmail.com>wrote:

> Hi Vali,
>
> well that was a lot helpful, but if i may, there was some few steps i did
> in order to to make the building successful,
>
> 1 - i added the following libraries in additional dependencies in linker
> pjlib-i386-Win32-vc8-release-dynamic.lib
> pjmedia-codec-i386-Win32-vc8-release-dynamic.lib
> pjmedia-i386-Win32-vc8-release-dynamic.lib
> pjmedia-audiodev-i386-Win32-vc8-release-dynamic.lib
> pjsip-core-i386-Win32-vc8-release-dynamic.lib
> pjsip-simple-i386-Win32-vc8-release-dynamic.lib
> pjsip-ua-i386-Win32-vc8-release-dynamic.lib
>
> 2- i also added their paths in the Additional libraries directories
>
> what made me do this, is that there was an older mail with a same issue and
> the guy solved it by including these libraries
>
> now, pjsua build successfully, except for one thing, that i can't find the
> dll file :)
>
> is there anything more i should do or anything wrong with including those
> libraries?
>
>
>
> On Thu, Jan 13, 2011 at 1:29 PM, Tom?? Valenta <vali at kamarad.cz> wrote:
>
>> Hi Hesham,
>>
>> I was too brief describing the last step. You must make getopt.h and
>> getopt.c look like other PJLIB headers, sources. I.e. begin getopt.h with
>> PJ_BEGIN_DECL (I think you have to #include <pj/config.h>, if it is not) and
>> end with PJ_END_DECL. All public declarations must be made using PJ_DECL or
>> PJ_DECL_DATA macros. Symbols declared in such way must be defined using
>> PJ_DEF or PJ_DEF_DATA respectively in getopt.c.
>>
>> I do not know why, but I experienced this was not enough. Adding
>> _pj_getopt_long to Force reference symbols linker option at PJSUA_LIB
>> project does the job.
>>
>> I would like to suggest this patch to be merged with the trunk source
>> code. Maybe it is just a problem of Visual Studio but the proposed changes
>> are harmless on other platforms.
>>
>> Vali
>>
>>
>> Dne 12.1.2011 10:16, Hesham Abboud napsal(a):
>>
>>>  Hi Vali,
>>>
>>> Thanks a lot for your reply, it really helped,
>>>
>>> but, when i tried to make the steps 5, 6 and 7, 4 external link errors
>>> didn't want to be resolved. i tried googling them but couldn't find any
>>> help, i'll show them below, also, when u wrote in step 6
>>> "pjmedia/src/pjmedia/enpoint.c:52 Use PJ_DEF_DATA", did u mean to make
>>> the line like this
>>> PJ_DEF_DATA(pj_bool_t) pjmedia_add_rtpmap_for_static_pt =
>>> or what because i didn't understand it so well?
>>>
>>> the errors are:
>>>
>>> Error1error LNK2001: unresolved external symbol
>>>
>>> _pj_getopt_longpjsua_app.objpjsua
>>> Error2error LNK2019: unresolved external symbol _pj_optarg referenced in
>>>
>>> function _parse_argspjsua_app.objpjsua
>>> Error3error LNK2019: unresolved external symbol _pj_optind referenced in
>>>
>>> function _parse_argspjsua_app.objpjsua
>>> Error4fatal error LNK1120: 3 unresolved
>>>
>>> externals..\bin\pjsua-i386-Win32-vc8-Release-Dynamic.exepjsua
>>>
>>>
>>> On Mon, Jan 10, 2011 at 11:54 PM, Tom?? Valenta <vali at kamarad.cz
>>> <mailto:vali at kamarad.cz>> wrote:
>>>
>>>    Hi Hesham,
>>>
>>>    it looks like you do not link with WinSock, add ws2_32.lib and/or
>>>    wsock.lib or something like that. It should be first link in google.
>>>
>>>    Cheers
>>>    - Vali
>>>
>>>    PS. Benny, in case you read this conversation, aren't you interested
>>>    in applying suggested patch to be able to build PJSUA using
>>>    pjsua_lib.dll easily?
>>>
>>>
>>>    Dne 10.1.2011 14:53, Hesham Abboud napsal(a):
>>>
>>>        Hi Tomas,
>>>
>>>        I'm developing a SIP phone on windows mobile for my company. After
>>>        searching a lot, I found the only project which done the same
>>> thing
>>>        using pjsip is Sipek project. Also the project made a dll file
>>>        wrapping
>>>        pjsip and used it. The problem is that, the working in the
>>>        project has
>>>        been stopped for over a year now and the dll file was made about
>>>        2 years
>>>        ago, so I can't use it effectively or modify in it. For these
>>>        reasons I
>>>        decided to make my own dll file. Searching for how to do so
>>>        showed me ur
>>>        e-mail so I tried to do the steps u mentioned. I made the steps
>>>        1, 2 and
>>>        3 but unfortunately a list of errors appeared and building
>>>        failed. I'll
>>>        list the errors below, but do u have any suggestions on how to
>>>        approach
>>>        what I want?
>>>
>>>        thanks in advance
>>>
>>>        Error18error LNK2019: unresolved external symbol __imp__ntohs at 4
>>>        referenced in function
>>>        _pj_ntohspjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error19error LNK2001: unresolved external symbol
>>>        __imp__ntohs at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error20error LNK2019: unresolved external symbol __imp__htons at 4
>>>        referenced in function
>>>        _pj_htonspjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error21error LNK2001: unresolved external symbol
>>>        __imp__htons at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error22error LNK2019: unresolved external symbol __imp__ntohl at 4
>>>        referenced in function
>>>        _pj_ntohlpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error23error LNK2001: unresolved external symbol
>>>        __imp__ntohl at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error24error LNK2001: unresolved external symbol
>>>        __imp__ntohl at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error25error LNK2001: unresolved external symbol
>>>        __imp__ntohl at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error26error LNK2019: unresolved external symbol __imp__htonl at 4
>>>        referenced in function
>>>        _pj_htonlpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error27error LNK2001: unresolved external symbol
>>>        __imp__htonl at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error28error LNK2001: unresolved external symbol
>>>        __imp__htonl at 4libsrtp-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error29error LNK2019: unresolved external symbol
>>> __imp__inet_ntoa at 4
>>>        referenced in function
>>>        _pj_inet_ntoapjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error30error LNK2019: unresolved external symbol
>>> __imp__inet_addr at 4
>>>        referenced in function
>>>        _pj_inet_atonpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error31error LNK2019: unresolved external symbol
>>>
>>>        __imp__WSAStringToAddressA at 20 referenced in function
>>>        _pj_inet_ptonpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error32error LNK2019: unresolved external symbol
>>>
>>>        __imp__WSAAddressToStringA at 20 referenced in function
>>>        _pj_inet_ntoppjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error33error LNK2019: unresolved external symbol
>>>        __imp__gethostname at 8
>>>        referenced in function
>>>        _pj_gethostnamepjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error34error LNK2019: unresolved external symbol
>>>
>>>        __imp__WSAGetLastError at 0 referenced in function
>>>        _pj_sock_socketpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error35error LNK2001: unresolved external symbol
>>>
>>>  __imp__WSAGetLastError at 0pjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error36error LNK2001: unresolved external symbol
>>>
>>>  __imp__WSAGetLastError at 0pjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error37error LNK2019: unresolved external symbol
>>>        __imp__WSASocketA at 24
>>>        referenced in function
>>>        _pj_sock_socketpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error38error LNK2019: unresolved external symbol __imp__bind at 12
>>>        referenced in function
>>>        _pj_sock_bindpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error39error LNK2019: unresolved external symbol
>>>        __imp__closesocket at 4
>>>        referenced in function
>>>        _pj_sock_closepjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error40error LNK2019: unresolved external symbol
>>>        __imp__getpeername at 12
>>>        referenced in function
>>>
>>>  _pj_sock_getpeernamepjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error41error LNK2019: unresolved external symbol
>>>        __imp__getsockname at 12
>>>        referenced in function
>>>
>>>  _pj_sock_getsocknamepjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error42error LNK2019: unresolved external symbol __imp__send at 16
>>>        referenced in function
>>>        _pj_sock_sendpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error43error LNK2019: unresolved external symbol __imp__sendto at 24
>>>        referenced in function
>>>        _pj_sock_sendtopjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error44error LNK2019: unresolved external symbol __imp__recv at 16
>>>        referenced in function
>>>        _pj_sock_recvpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error45error LNK2019: unresolved external symbol
>>> __imp__recvfrom at 24
>>>        referenced in function
>>>        _pj_sock_recvfrompjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error46error LNK2019: unresolved external symbol
>>>        __imp__getsockopt at 20
>>>        referenced in function
>>>
>>>  _pj_sock_getsockoptpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error47error LNK2019: unresolved external symbol
>>>        __imp__setsockopt at 20
>>>        referenced in function
>>>
>>>  _pj_sock_setsockoptpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error48error LNK2019: unresolved external symbol __imp__connect at 12
>>>        referenced in function
>>>        _pj_sock_connectpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error49error LNK2019: unresolved external symbol __imp__shutdown at 8
>>>        referenced in function
>>>        _pj_sock_shutdownpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error50error LNK2019: unresolved external symbol __imp__listen at 8
>>>        referenced in function
>>>        _pj_sock_listenpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error51error LNK2019: unresolved external symbol __imp__accept at 12
>>>        referenced in function
>>>        _pj_sock_acceptpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error52error LNK2019: unresolved external symbol
>>> __imp__WSAStartup at 8
>>>        referenced in function
>>>        _pj_initpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error53error LNK2019: unresolved external symbol
>>> __imp__WSACleanup at 0
>>>        referenced in function
>>>        _pj_shutdownpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error54error LNK2019: unresolved external symbol
>>>
>>>        __imp__WSASetLastError at 4 referenced in function
>>>
>>>  _pj_set_netos_errorpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error55error LNK2019: unresolved external symbol
>>>        __imp__gethostbyname at 4
>>>        referenced in function
>>>        _pj_gethostbynamepjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error56error LNK2019: unresolved external symbol
>>>        __imp__ioctlsocket at 12
>>>        referenced in function
>>>
>>>  _pj_ioqueue_register_sockpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error57error LNK2019: unresolved external symbol ___WSAFDIsSet at 8
>>>        referenced in function
>>>        _PJ_FD_ISSETpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error58error LNK2019: unresolved external symbol __imp__select at 20
>>>        referenced in function
>>>        _pj_sock_selectpjlib-i386-win32-vc8-release-dynamic.libpjsua_lib
>>>        Error59fatal error LNK1120: 32 unresolved
>>>
>>>  externals..\bin\pjsua_lib-i386-Win32-vc8-Release-Dynamic.exepjsua_lib
>>>
>>>
>>>
>>>        On Tue, Dec 14, 2010 at 9:41 PM, Tom?? Valenta <vali at kamarad.cz
>>>        <mailto:vali at kamarad.cz>
>>>        <mailto:vali at kamarad.cz <mailto:vali at kamarad.cz>>> wrote:
>>>
>>>            Hi,
>>>
>>>            recently I tried to compile pjsua_lib 1.8.10 as a single DLL
>>> for
>>>            using in our application. We are migrating from 1.0.3.
>>>        Everything
>>>            went fairly OK with some obstacles, though. Here I would like
>>> to
>>>            write down the steps I made and fixes if there were problems.
>>>
>>>            1. Opened in Visual Studio 2008, chosen Release-Dynamic
>>>            configuration on Win32 platform.
>>>            2. Put following in config_site.h:
>>>            #define PJ_DLL 1
>>>            #ifdef _LIB
>>>            #       define PJ_EXPORTING 1
>>>            #endif
>>>            3. Set dependencies of pjsua_lib to the same as libpjproject
>>>        and set
>>>            its configuration type to DLL. Also added
>>>        _pjmedia_tonegen_create2
>>>            to Force reference symbols in linker options, because this
>>>        symbol
>>>            would not be available otherwise.
>>>            4. Built pjsua_lib project. This was enough for our
>>> application
>>>            needs, but to make PJSUA using this DLL following steps must
>>>        be taken:
>>>
>>>            5. Set PJSUA's dependencies to pjsua_lib only. Now when tried
>>> to
>>>            build PJSUA, following Unresolved externals appeared:
>>>            _pjmedia_add_rtpmap_for_static_pt
>>>            _pjsip_include_allow_hdr_in_dlg
>>>            _pjsip_use_compact_form
>>>            _pj_optarg
>>>            _pj_getopt_long
>>>            _pj_optind
>>>            (And also some _pjmedia_tonegen_... if not set in step 3.)
>>>
>>>            6. Following lines must be patched:
>>>            pjmedia/src/pjmedia/enpoint.c:52 Use PJ_DEF_DATA
>>>            pjsip/src/pjsip/sip_dialog.c:44  Use PJ_DEF_DATA
>>>            pjsip/src/pjsip/sip_msg.c:147    Use PJ_DEF_DATA
>>>            pjsip-apps/src/pjsua/pjsua_app.c:962--964 Use PJ_DECL_DATA
>>>            pjsip-apps/src/pjsua/pjsua_app.c:1676     Use PJ_DECL_DATA
>>>            Also add PJ_DECL and PJ_DEF macros to
>>>        pjlib-util/src/pjlib-util/getopt.*
>>>            And put to the PJSUA's Force reference symbols also
>>>        _pj_getopt_long.
>>>
>>>            7. Now PJSUA compiles and works correctly.
>>>
>>>            I hope this post will be useful for someone and the suggested
>>>            patches will be applied to the trunk, because I think this
>>>        is the
>>>            way it should be done, but correct me if I am wrong.
>>>
>>>            Cheers,
>>>            - Vali
>>>
>>>            PS. Have you any idea, why "Force reference symbols" must be
>>> set
>>>            sometimes?
>>>
>>>            _______________________________________________
>>>            Visit our blog: http://blog.pjsip.org
>>>
>>>            pjsip mailing list
>>>        pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>>>        <mailto:pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>>
>>>
>>>
>>>        http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>>>
>>>
>>>
>>>
>>>        --
>>>        Eng. Hesham Abboud
>>>        +20123185749
>>>
>>>
>>>
>>>        _______________________________________________
>>>        Visit our blog: http://blog.pjsip.org
>>>
>>>        pjsip mailing list
>>>        pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>>>        http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>>>
>>>
>>>
>>>    _______________________________________________
>>>    Visit our blog: http://blog.pjsip.org
>>>
>>>    pjsip mailing list
>>>    pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org>
>>>    http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>>>
>>>
>>>
>>>
>>> --
>>> Eng. Hesham Abboud
>>> +20123185749
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Eng. Hesham Abboud
> +20123185749
>



-- 
Eng. Hesham Abboud
+20123185749
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110119/5c000ad9/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux