When I try to compile a project with winsock function DoWinsock I get this error:
libwsock32.a is already included...Code:[Linker error] undefined reference to `DoWinsock(char const*, int)'
When I try to compile a project with winsock function DoWinsock I get this error:
libwsock32.a is already included...Code:[Linker error] undefined reference to `DoWinsock(char const*, int)'
Tell us your OS and compiler (I'm guessing Linux / UNIX and GCC judging by libwsock32.a) and post up your code so far.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Try linking this library as well: libws2_32.a. I am pretty sure that there are two different libraries you need to link for all the Winsock functions to "be defined". I'm sure you are including the winsock header file?
Trinity: "Neo... nobody has ever done this before."
Neo: "That's why it's going to work."
c9915ec6c1f3b876ddf38514adbb94f0
Yes, I'm sure I included winsock header file (winsock.h) and I already tried to link both libraries (libwsock32.a and libws2_32.a). Didn't help...
I know someone who had a similar incident once, apparently his winsock headers were buggered, but I doubt it's that.
What version are you using?
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Is DoWinsock() even an API function Because to me it looks like you either called a function that was declared after the function it was called in and youf ailed to prototype it.
for example:
Would nto work and would give you a link error, you need to add:Code:void a() { b(); } void b() { //whatever }
to the top of the file for that to work properly. I think that is your problem.Code:void b();
Undefined reference should mean its defined, but can't find the library function for it...
I don't know exactly, not winsock 2, some older version...
Last edited by maxorator; 10-09-2005 at 09:30 AM.
Code:extern int DoWinsock(const char* pcHost, int nPort);
I need to link the project with wsock32.lib to get it to work so I guess you could try that?
It'll probably be version 1.0 (I think) then.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Where did you find this function? I'm pretty sure it isn't part of the winsock library...
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
MSDN doesn't have anything on it, but I found several sites that talk about it like it is.
From what I can make out, it's a member function of some winsock wrapper class which someone created.
You need the whole class .cpp/.h or .lib/.h or .dll/.h combo in order to make the code work.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Perhaps you should read the FAQ before blindly using it's code. http://tangentsoft.net/wskfaq/exampl...sic-client.cpp
seems like a poorly named function too, just how does one do winsock?