[Winpcap-users] Entry Point in a DLL

George S. Lockwood gslockwood
Sun Aug 6 21:02:31 PDT 2006


Hello Tom,

So far I have simply put the class definition within a cpp file I created by
first copying wpa_cli.c to cwpa.cpp, then putting the following code in near
the top.  The action_file = NULL; line below is the last line of the
original wpa_cli code.  This does the same thing as putting the prototypes
in the .h file I created to declare the cwpa class (yes I could and will
when this issue is resolved, put them in the .h file).

You can see that I have prototyped the functions I call in the destructor
(that's as far as I went before doing an initial build attempt!!).  The
wpa_cli_cleanup function is defined in this cpp file, but the other 2 are in
os_win32.c which is included in the project.

The errors:
CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl
os_program_deinit(void)" (?os_program_deinit@@YAXXZ)
CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl
os_daemonize_terminate(char const *)" (?os_daemonize_terminate@@YAXPBD at Z)

I believe the problem that the VS compiler compiles functions in .c files
differenctly than .cpp files (is this mangling?), so I believe there is a
function declaration keyword I need to use in conjunction with "extern" in
order to tell the C++ compiler that these are c-style functions.

If this is true, Yes you might be right about VS having too many ways of
doing things...I've forgotten more than I remember!! Throw C# in the mix and
things really get foggy.

Here's the code:

static const char *action_file = NULL;

// gsl added
void wpa_cli_cleanup(void);

extern void os_program_deinit(void);
extern void os_daemonize_terminate(const char *pid_file);

CWPA::CWPA()
{
    wpa_cli_quit = 0;
    wpa_cli_attached = 0;

    //gsl implement this later
    wpa_cli_monitor_attached = 0;

    wpa_cli_connected = 0;
    wpa_cli_last_id = 0;
    //strcpy_s( ctrl_iface_dir, _countof( ctrl_iface_dir ),
"/var/run/wpa_supplicant" );    // does this change in windows run
    ctrl_ifname = NULL;
    pid_file = NULL;
    action_file = NULL;
}
CWPA::~CWPA()
{
    free(ctrl_ifname);
    wpa_cli_cleanup();
}

.
.
.


On 8/6/06, Thomas O'Hare <Tom at redtile.com> wrote:
>
> FWIW, put it in your own "h" file for that part of your project.  That
> should declare it or prototype it for use.
>
> Thanks,
> ~ Thomas O'Hare ~
> President, RedTile, Inc. - DBA: RedTile Software
> Web, Wireless, Network, Database & Systems Software
> +1.407.295.9148 ; +49.8651.717950 ; http://www.RedTile.Com/
> Operations Manager; Virtual FoxPro User Group
> Tom at VFUG.Org ; http://www.VFUG.Org/
>
>
> George S. Lockwood wrote:
> > Here's an example:
> >
> > CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl
> > wpa_cli_cleanup(void)" (?wpa_cli_cleanup@@YAXXZ).
> >
> > this comes from putting a call to wpa_cli_cleanup() in the destructor of
> > the
> > class I'm trying to make.  It is not a call to winpcap's dlls but to
> > wpa_cli
> > code C code (actually to its .objs).
> >
> > george
> >
> > On 8/6/06, Gianluca Varenni <gianluca.varenni at cacetech.com> wrote:
> >>
> >>  WinPcap can be used within a C++ application without any problem, you
> >> don't need extern "C" or similar stuff.
> >>
> >> What is the exact linking error you are encountering?
> >>
> >> Have a nice day
> >> GV
> >>
> >> ----- Original Message -----
> >> *From:* George S. Lockwood <gslockwood at gmail.com>
> >> *To:* Tom at redtile.com ; winpcap-users at winpcap.org
> >> *Sent:* Saturday, August 05, 2006 11:28 AM
> >> *Subject:* Re: [Winpcap-users] Entry Point in a DLL
> >>
> >> Hello Thomas,
> >>
> >> I think I'm trying to do something similar but with a standard library
> I
> >> (think) am statically linking.  I'm getting link errors about
> unresolved
> >> externals.  I am try to build the wpa_cli into a class.
> >>
> >> I think my problem is about a class (cpp) file not understanding a lib
> >> build from straight "C" and thereby not finding a c style functions.
> >>
> >> Either I'm getting forgetful (very possible), or involved with .net too
> >> much too recently to remember (also possible) that I'm forgeting the
> >> way to
> >> link C-style functions into a cpp module and call those external
> >> functions.
> >>
> >> What am I forgetting?? Or am I forgetting that it is impossible.  I
> >> thought I needed to declare the externals with something like __decl
> >> or with
> >> "C"    inside the cpp file???????
> >>
> >>
> >>
> >>
> >> thanks for any of your ideas,
> >>
> >> george
> >>
> >> On 8/3/06, Thomas O'Hare <Tom at redtile.com> wrote:
> >> >
> >> > Hello All!
> >> >
> >> > I am using Dev-C++ in C++ mode to try and create an entry point into
> my
> >> > own DLL's based on the WinPCap Libraries.  I need to export several
> of
> >> > my own functions to languages that do not inherently support C typed
> >> > structures.
> >> >
> >> > I am looking for the cleanest, fasted way to create an entry point
> for
> >> > my functions so I can use the DLL as a true library for the
> programming
> >> > languages lacking native structure support.
> >> >
> >> > I can open DLL's in these languages and call functions, but
> especially
> >> > "chained" (Next) structures are very very tricky to work with in any
> >> > language that does not have native support for C typed structures.
> >> >
> >> > Any docs, resources, suggestions, etc, are welcome.
> >> > --
> >> >
> >> > Thanks,
> >> > ~ Thomas O'Hare ~
> >> > President, RedTile, Inc. - DBA: RedTile Software
> >> > Web, Wireless, Network, Database & Systems Software
> >> > +1.407.295.9148 ; +49.8651.717950 ; http://www.RedTile.Com/
> >> > Operations Manager; Virtual FoxPro User Group
> >> > Tom at VFUG.Org ; http://www.VFUG.Org/
> >> > _______________________________________________
> >> > Winpcap-users mailing list
> >> > Winpcap-users at winpcap.org
> >> > https://www.winpcap.org/mailman/listinfo/winpcap-users
> >> >
> >>
> >>  ------------------------------
> >>
> >> _______________________________________________
> >> Winpcap-users mailing list
> >> Winpcap-users at winpcap.org
> >> https://www.winpcap.org/mailman/listinfo/winpcap-users
> >>
> >>
> >> _______________________________________________
> >> Winpcap-users mailing list
> >> Winpcap-users at winpcap.org
> >> https://www.winpcap.org/mailman/listinfo/winpcap-users
> >>
> >>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Winpcap-users mailing list
> > Winpcap-users at winpcap.org
> > https://www.winpcap.org/mailman/listinfo/winpcap-users
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.shmoo.com/pipermail/hostap/attachments/20060806/78655537/attachment.htm 



More information about the Hostap mailing list