Linker errors on Winsock2 functions

This is a discussion on Linker errors on Winsock2 functions within the C++ Programming forums, part of the General Programming Boards category; I keep getting linker errors for winsock2 functions whenever I compile. I'm using DevC++ with the default compiler. It's definately ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    40

    Linker errors on Winsock2 functions

    I keep getting linker errors for winsock2 functions whenever I compile. I'm using DevC++ with the default compiler. It's definately not a code problem. It's got to be something in the Options somewhere. Anyone got an idea?
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    You need to link to libws2_32.a

    Im not familiar with devc++, so I'm not exactly sure how you tell the linker which libraries to link to, but it's probably in the options somewhere.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    Ahhh. Thanks, man. Worked great.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker errors with Templates...
    By Petike in forum C++ Programming
    Replies: 2
    Last Post: 09-03-2008, 10:52 AM
  2. linker errors:
    By elninio in forum Linux Programming
    Replies: 12
    Last Post: 07-27-2008, 09:52 PM
  3. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 08:42 AM
  4. Linker errors when compiling
    By The Wazaa in forum C++ Programming
    Replies: 4
    Last Post: 10-07-2006, 01:55 PM
  5. Linker errors with simple static library
    By Dang in forum Windows Programming
    Replies: 5
    Last Post: 09-08-2001, 10:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21