Thread: Can't resolve linker error!!!!

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    2

    Can't resolve linker error!!!!

    Hi,
    I'm having trouble getting this linker bug to go away.
    I have 2 files: Socket.cpp and Socket.h. I know that these files are legitamite because my professor gave them to me during last semester.

    When I remove socket.cpp, everything compiles just fine. But with Socket.cpp, I get these errors.

    __________________________________________________ _____________
    Error 16 error LNK2001: unresolved external symbol ___WSAFDIsSet@8 socket.obj
    Error 11 error LNK2001: unresolved external symbol __imp__accept@12 socket.obj
    Error 9 error LNK2001: unresolved external symbol __imp__bind@12 socket.obj
    Error 4 error LNK2001: unresolved external symbol __imp__closesocket@4 socket.obj
    Error 14 error LNK2001: unresolved external symbol __imp__connect@12 socket.obj
    Error 13 error LNK2001: unresolved external symbol __imp__gethostbyname@4 socket.obj
    Error 8 error LNK2001: unresolved external symbol __imp__htons@4 socket.obj
    Error 5 error LNK2001: unresolved external symbol __imp__ioctlsocket@12 socket.obj
    Error 10 error LNK2001: unresolved external symbol __imp__listen@8 socket.obj
    Error 6 error LNK2001: unresolved external symbol __imp__recv@16 socket.obj
    Error 15 error LNK2001: unresolved external symbol __imp__select@20 socket.obj
    Error 7 error LNK2001: unresolved external symbol __imp__send@16 socket.obj
    Error 3 error LNK2001: unresolved external symbol __imp__socket@12 socket.obj
    Error 2 error LNK2001: unresolved external symbol __imp__WSACleanup@0 socket.obj
    Error 12 error LNK2001: unresolved external symbol __imp__WSAGetLastError@0 socket.obj
    Error 1 error LNK2001: unresolved external symbol __imp__WSAStartup@8 socket.obj
    Error 17 fatal error LNK1120: 16 unresolved externals C:\Users\Ben\Desktop\Documents\Visual Studio 2008\Projects\ConnectionDLL2\Release\ConnectionDLL 2.dll
    -----------------------------------------------------------------------------------------------------

    Socket.h includes
    #include <WinSocket.h>
    #include <string>
    #include "ConnectionDLL2.h"


    Socket.cpp includes...
    #include "stdafx.h"
    --> Which includes
    #pragma once
    #include "targetver.h"
    #include <stdio.h>
    #include <windows.h>
    #include <iostream>
    #include <string>
    #include <list>
    #include <map>
    #include <algorithm>
    #include <queue>
    #include <process.h>
    #include <strstream>
    using namespace std;
    #include "Socket.h"


    Thanks

    ~Ben S.

  2. #2

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2
    Hey. So I figured it out and it was pretty basic.
    All I needed to do was include "ws2_32.lib", I did this
    through the code: #pragma comment(lib, "ws2_32.lib").

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Just so you know, #pragma is non-standard and might not work on all compilers. (I don't think Dev-C++ supports it, for example; and I'm almost certain most Linux compilers don't either.) On the other hand, if you're using lots of non-standard code, then it probably doesn't matter.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM