![]() |
|
[C] Windows Library Header Troubles - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] Windows Library Header Troubles (/showthread.php?tid=5979472) |
Windows Library Header Troubles - asterisk - Jun 13, 2019 I've been writing a client side socket in C++ from a tutorial, and I haven't quite gotten my head around some of it yet. I've included many windows library headers, but none of them appear to be recognized by the compiler. It begins flagging every identifier in these libraries as undefined and even some of the ones I have created myself. The editor recognizes the code as completely correct, and tells me there are no issues, but the compiler throws over a hundred errors, most all linked to an undeclared identifier. Some examples of supposedly undeclared identifiers include WSADATA, send(), and some of the most basic functions and classes from these headers. I included the header files windows.h, iostream, winsock2.h, ws2tcpip.h, and fstream. I initialized the socket libraries with "#pragma comment(lib, "Ws_32.lib")". Whatever help you can give is much appreciated. RE: Windows Library Header Troubles - binbus - Jun 13, 2019 Try to include winsock2.h before windows.h RE: Windows Library Header Troubles - lynxmk - Jun 13, 2019 And also compile with -lws2_32 parameter. RE: Windows Library Header Troubles - YouthInAsia - Jun 13, 2019 (Jun 13, 2019 12:58 PM)lynxmk Wrote: And also compile with -lws2_32 parameter. He already did pragma comment (lib,"ws232"); RE: Windows Library Header Troubles - asterisk - Jun 13, 2019 (Jun 13, 2019 12:58 PM)lynxmk Wrote: And also compile with -lws2_32 parameter. How would I add a parameter to Visual Studio? I probably shouldn't be using a platform like that, but it's the only one I'm comfortable with at the moment. (Jun 13, 2019 12:49 PM)binbus Wrote: Try to include winsock2.h before windows.h The fact that this eliminated so many error messages doesn't seem right to me. That is that something so trivial would matter so much. RE: Windows Library Header Troubles - dracx - Jun 13, 2019 (Jun 13, 2019 04:32 PM)asterisk Wrote: How would I add a parameter to Visual Studio? I probably shouldn't be using a platform like that, but it's the only one I'm comfortable with at the moment. yes, try winsock2.h before windows.h, if you are having linker issues, yeah, you might try and add ws2_32.lib from your solution->properties->linker->input RE: Windows Library Header Troubles - 0xDEAD10CC - Jun 15, 2019 (Jun 13, 2019 04:32 PM)asterisk Wrote: How would I add a parameter to Visual Studio? I probably shouldn't be using a platform like that, but it's the only one I'm comfortable with at the moment. He didn't know what he was talking about, don't listen to him. That command line linker option isn't even for the MS compiler. RE: Windows Library Header Troubles - Irritiable - Jun 16, 2019 (Jun 13, 2019 12:46 PM)asterisk Wrote: I've been writing a client side socket in C++ from a tutorial, and I haven't quite gotten my head around some of it yet. I've included many windows library headers, but none of them appear to be recognized by the compiler. It begins flagging every identifier in these libraries as undefined and even some of the ones I have created myself. The editor recognizes the code as completely correct, and tells me there are no issues, but the compiler throws over a hundred errors, most all linked to an undeclared identifier. Post your errors. You probably need to link the library with the functions. |