Hello Tom,<br><br>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).
<br><br>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.
<br><br>The errors:<br>CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl os_program_deinit(void)" (?os_program_deinit@@YAXXZ)<br>CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl os_daemonize_terminate(char const *)" (?os_daemonize_terminate@@
YAXPBD@Z)<br><br>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.
<br><br>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.<br><br>Here's the code:<br><br>static const char *action_file = NULL;
<br><br>// gsl added<br>void wpa_cli_cleanup(void);<br><br>extern void os_program_deinit(void);<br>extern void os_daemonize_terminate(const char *pid_file);<br><br>CWPA::CWPA()<br>{<br> wpa_cli_quit = 0;<br> wpa_cli_attached = 0;
<br><br> //gsl implement this later<br> wpa_cli_monitor_attached = 0;<br><br> wpa_cli_connected = 0;<br> wpa_cli_last_id = 0;<br> //strcpy_s( ctrl_iface_dir, _countof( ctrl_iface_dir ), "/var/run/wpa_supplicant" ); // does this change in windows run
<br> ctrl_ifname = NULL;<br> pid_file = NULL;<br> action_file = NULL;<br>}<br>CWPA::~CWPA()<br>{<br> free(ctrl_ifname);<br> wpa_cli_cleanup();<br>}<br><br>.<br>.<br>.<br><br><br><div><span class="gmail_quote">
On 8/6/06, <b class="gmail_sendername">Thomas O'Hare</b> <<a href="mailto:Tom@redtile.com">Tom@redtile.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
FWIW, put it in your own "h" file for that part of your project. That<br>should declare it or prototype it for use.<br><br>Thanks,<br>~ Thomas O'Hare ~<br>President, RedTile, Inc. - DBA: RedTile Software<br>Web, Wireless, Network, Database & Systems Software
<br>+1.407.295.9148 ; +49.8651.717950 ; <a href="http://www.RedTile.Com/">http://www.RedTile.Com/</a><br>Operations Manager; Virtual FoxPro User Group<br><a href="mailto:Tom@VFUG.Org">Tom@VFUG.Org</a> ; <a href="http://www.VFUG.Org/">
http://www.VFUG.Org/</a><br><br><br>George S. Lockwood wrote:<br>> Here's an example:<br>><br>> CWPA.obj : error LNK2001: unresolved external symbol "void __cdecl<br>> wpa_cli_cleanup(void)" (?wpa_cli_cleanup@@YAXXZ).
<br>><br>> this comes from putting a call to wpa_cli_cleanup() in the destructor of<br>> the<br>> class I'm trying to make. It is not a call to winpcap's dlls but to<br>> wpa_cli<br>> code C code (actually to its .objs).
<br>><br>> george<br>><br>> On 8/6/06, Gianluca Varenni <<a href="mailto:gianluca.varenni@cacetech.com">gianluca.varenni@cacetech.com</a>> wrote:<br>>><br>>> WinPcap can be used within a C++ application without any problem, you
<br>>> don't need extern "C" or similar stuff.<br>>><br>>> What is the exact linking error you are encountering?<br>>><br>>> Have a nice day<br>>> GV<br>>><br>>> ----- Original Message -----
<br>>> *From:* George S. Lockwood <<a href="mailto:gslockwood@gmail.com">gslockwood@gmail.com</a>><br>>> *To:* <a href="mailto:Tom@redtile.com">Tom@redtile.com</a> ; <a href="mailto:winpcap-users@winpcap.org">
winpcap-users@winpcap.org</a><br>>> *Sent:* Saturday, August 05, 2006 11:28 AM<br>>> *Subject:* Re: [Winpcap-users] Entry Point in a DLL<br>>><br>>> Hello Thomas,<br>>><br>>> I think I'm trying to do something similar but with a standard library I
<br>>> (think) am statically linking. I'm getting link errors about unresolved<br>>> externals. I am try to build the wpa_cli into a class.<br>>><br>>> I think my problem is about a class (cpp) file not understanding a lib
<br>>> build from straight "C" and thereby not finding a c style functions.<br>>><br>>> Either I'm getting forgetful (very possible), or involved with .net too<br>>> much too recently to remember (also possible) that I'm forgeting the
<br>>> way to<br>>> link C-style functions into a cpp module and call those external<br>>> functions.<br>>><br>>> What am I forgetting?? Or am I forgetting that it is impossible. I<br>>> thought I needed to declare the externals with something like __decl
<br>>> or with<br>>> "C" inside the cpp file???????<br>>><br>>><br>>><br>>><br>>> thanks for any of your ideas,<br>>><br>>> george<br>>><br>>> On 8/3/06, Thomas O'Hare <
<a href="mailto:Tom@redtile.com">Tom@redtile.com</a>> wrote:<br>>> ><br>>> > Hello All!<br>>> ><br>>> > I am using Dev-C++ in C++ mode to try and create an entry point into my<br>>> > own DLL's based on the WinPCap Libraries. I need to export several of
<br>>> > my own functions to languages that do not inherently support C typed<br>>> > structures.<br>>> ><br>>> > I am looking for the cleanest, fasted way to create an entry point for<br>
>> > my functions so I can use the DLL as a true library for the programming<br>>> > languages lacking native structure support.<br>>> ><br>>> > I can open DLL's in these languages and call functions, but especially
<br>>> > "chained" (Next) structures are very very tricky to work with in any<br>>> > language that does not have native support for C typed structures.<br>>> ><br>>> > Any docs, resources, suggestions, etc, are welcome.
<br>>> > --<br>>> ><br>>> > Thanks,<br>>> > ~ Thomas O'Hare ~<br>>> > President, RedTile, Inc. - DBA: RedTile Software<br>>> > Web, Wireless, Network, Database & Systems Software
<br>>> > +1.407.295.9148 ; +49.8651.717950 ; <a href="http://www.RedTile.Com/">http://www.RedTile.Com/</a><br>>> > Operations Manager; Virtual FoxPro User Group<br>>> > <a href="mailto:Tom@VFUG.Org">
Tom@VFUG.Org</a> ; <a href="http://www.VFUG.Org/">http://www.VFUG.Org/</a><br>>> > _______________________________________________<br>>> > Winpcap-users mailing list<br>>> > <a href="mailto:Winpcap-users@winpcap.org">
Winpcap-users@winpcap.org</a><br>>> > <a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br>>> ><br>>><br>>> ------------------------------
<br>>><br>>> _______________________________________________<br>>> Winpcap-users mailing list<br>>> <a href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</a><br>>> <a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">
https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br>>><br>>><br>>> _______________________________________________<br>>> Winpcap-users mailing list<br>>> <a href="mailto:Winpcap-users@winpcap.org">
Winpcap-users@winpcap.org</a><br>>> <a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br>>><br>>><br>>><br>><br>><br>
> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> Winpcap-users mailing list<br>> <a href="mailto:Winpcap-users@winpcap.org">
Winpcap-users@winpcap.org</a><br>> <a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br>_______________________________________________<br>Winpcap-users mailing list
<br><a href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</a><br><a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br></blockquote></div>
<br>