English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am using dev c++ and getting a linker error. I understand what it means somewhat, but I do not know how to fix it. Here is my program:

#include
#include
int main(int argc, char *argv[])
{ int starts, s; sockaddr_in sockin; WSAData *wsa;
if(WSAStartup(MAKEWORD(1,1),wsa))
return 1;
starts=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
sockin.sin_family=AF_INET;
sockin.sin_addr.s_addr = INADDR_ANY;
sockin.sin_port=htons(40254);
if(!bind(starts,(sockaddr *)&sockin,sizeof(struct sockaddr_in)))
return 2;
scanf("");
WSACleanup();
return 0;
}

i get undefined reference to: 'WSAStartup@8', socket@12, htons@4, bind@12, WSACleanup@0

I do not really understand how to link a .dll. Thanks for your help.

2007-03-13 12:50:03 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

response to chris's answer: I do not know how to link to a .lib. I don't know much lol. Also I ran search on hard drive for that file and got nothing.

2007-03-13 13:10:46 · update #1

3 answers

Link to wsock32.lib (regular windows) or ws2_32.lib (windows NT) using the Input\Additional Dependencies field on the Linker tab/folder of the project Properties.

2007-03-13 12:55:41 · answer #1 · answered by Chris J 6 · 2 0

I'm not familar with the above code, though the error seems to imply you're missing a linking library.

In Dev++, create a new project, delete main.cpp file created. From that point, right click on project, select add to project (you would add your own cpp file).

Linking. Right click on project, select project options. At that point it's a matter of using the built add object or library button to locate your missing linker file. Once found, click ok.

2007-03-13 16:40:44 · answer #2 · answered by Walt Kolo 2 · 0 0

spectacular now, extra effective() has no longer been defined. you have declared it, yet you have no longer written out the function physique. How is the pc meant to be attentive to what to do on that function call in case you have no longer presented a function physique? the pc can not examine your concepts, you ought to tell it what to do.

2016-11-25 01:29:48 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers