linker problem

Trying to compile a simple program in C++ I got a LNK error code.

Error 1 error LNK2028: unresolved token (0A00000B) "int __stdcall setsockopt(unsigned int,int,int,char const *,int)" ( setsockopt@@$$J220YGHIHHPBDH@Z) referenced in function "void __clrcall SocketPlusConnect(void)" ( SocketPlusConnect@@$$FYMXXZ) SocketsCplus.obj 

It is one a few.

Am I missing a header file or a few of them

Will appreciate any help.

Thanks.


Answer this question

linker problem

  • daniel kurtz

    No, I did not.

    Actually I used a MSDN sample code I fund at tis URL

    ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WIN32COM.v10.en/winsock/winsock/setsockopt_2.htm

    This snippet can be found under setsockopt with C++ flter in VS2005 help.

    All I did was to convert Main() into a subroutine. I christened it SocketPlusConnect
    It is a mnemonics issue for me.

    Thus getsockopt is a standard function.

    Thanks.


  • B.Young

    Did you included Ws2_32.lib into the list of libraries that the linker should use

    SocketPlusConnect seams to be a function of your own, that has no implementation.

  • wookie

    Did you wrote your own definition for setsocketopt. The name is mangled by C++ but it should be declared as extern "C"!

    Did you really used the standard winsock2 header

  • Ed__

    Thanks for the suggestion but the problem has not been resolved. I want to describe in detail what I did. Please review it. Perhaps I did something wrong.

    I found Ws2_32.lib in at least 4 directories in my computer and chose one of them: "C:\Program Files\Visual Studio 8\VC\PlatformSDK\Lib"

    Next I clicked on Project-->SocketCPlus Properties-->Configuration Properties-->Linker-->General in my Visual Studio 2005.

    SocketCPlus is just the asigned name for the project and the user defined function, you were correct, has name SocketPlusConnect.

    At Linker-->General I had a few options. First I changed "Ignore Import Library" from default "Yes" to "No." It was not very simple because a few times it reverted back to "Yes" but I persisted. Now it seems to have stuck.

    Next thing I entered the directory mentioned above into the slot: "Additional Library Directories" which was blank before.

    Then I changed "Use Library Dependency Inputs" from "No" to "Yes."

    I want to say that I made these two changes "Yes" to "No" and "No" to "Yes" just in case without real understanding but it seemed logical to me.

    I got the same 23 LNK errors.

    Please help.

    Thanks.

  • linker problem