Visual Studio #include
Results 1 to 9 of 9

Thread: Visual Studio #include

Hybrid View

  1. #1
    Member
    Join Date
    Sep 2007
    Posts
    51

    Question Visual Studio #include

    hey guys,

    i don't have too much experience of using MS Visual Studio, therefore i need some help. i am trying to write a program using WinSock in Visual C++, so could someone tell be what i need to do to include the "winsock.h" header file, in MS Visual Studio. Beyond the following.

    Code:
    #include <winsock.h>
    i've tried a number of solutions that i have found on the net, but non of them have completely worked. therefore could anyone help me?


    thanks in advance,

    - User0182

  2. #2
    Senior Member
    Join Date
    Dec 2001
    Posts
    319
    That is actually all you need to do. If that's not working, then you have problems somewhere else. What problems are you having with it, exactly?

  3. #3
    Member
    Join Date
    Sep 2007
    Posts
    51
    when i try to use WSAStartup(), then i get a build error. that says:

    error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _main

    which is why i think that the "winsock.h" library has not been included in the build. what do you think?

  4. #4
    Senior Member JPnyc's Avatar
    Join Date
    Jan 2005
    Posts
    2,734
    I haven't opened Visual Studio in years and I never used it for anything but Visual Basic, but as I recall there was a setting where you had to import a whole package that contained each library that you intend to reference. It's been too many years for me to tell you where to look and I have no idea how much the program has changed in that time.

    I had to do such an import myself just to reference the scripting.filesystem object.

  5. #5
    Member
    Join Date
    Sep 2007
    Posts
    51
    that's what i was thinking, that i may have to import the header file into my project.

    but, im not sure how to do that. all the attempts that i have made have been unsuccessful ;-(.

    although, i could easily be mistaken! anyone, that has any ideas how i could resolve this problem, please let me know.
    Last edited by user0182; April 24th, 2008 at 01:54 AM.

  6. #6
    Member
    Join Date
    Sep 2007
    Posts
    51
    thanks for your help guys, but i've worked out the answer to my own question! what i needed to do was, on the menus, go to:

    project -> properties -> "configuration properties" -> linker -> input -> "additional dependancies"

    and add "WS2_32.lib".


    - user0182

  7. #7
    Senior Member JPnyc's Avatar
    Join Date
    Jan 2005
    Posts
    2,734
    I'm glad you found it, I was about to tell you that the solution is not coding, but rather part of the menu interface. Anyway you solved it. Congrats!

  8. #8
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    It's actually a linker error. By adding the additional dependencies you're telling the linker to link the ws2_32.lib to your executable making it's functions available.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  9. #9
    Custom User
    Join Date
    Oct 2001
    Posts
    503
    Don't know if this'll help you at all, but generally if the problem was that VS couldn't find the header file you would get an error along the lines of:

    "Warning C4013: 'my_func' undefined; assuming extern, returning int"

    Another way that you can get an idea of whether the issue is a compiler or a linker problem is by looking at the error codes. Compiler problems start with Cxxxx whereas linker problems start with LNKxxxx.

    A good way to get help on these problems is to search by that error code.

    Cheers,
    ac

Similar Threads

  1. Help!! Compiler Troubles!!!
    By wolfman1984 in forum Programming Security
    Replies: 2
    Last Post: December 8th, 2007, 07:50 PM
  2. Optimized Settings for SNORT---Help?
    By Condoor in forum IDS & Scanner Discussions
    Replies: 1
    Last Post: March 21st, 2003, 02:34 AM
  3. C++ portability guide
    By tampabay420 in forum Programming Security
    Replies: 2
    Last Post: February 14th, 2003, 02:36 PM
  4. Snort + MySql Server error...
    By Condoor in forum AntiOnline's General Chit Chat
    Replies: 11
    Last Post: February 12th, 2003, 04:08 AM
  5. Another snort problem
    By ele5125 in forum IDS & Scanner Discussions
    Replies: 7
    Last Post: August 9th, 2002, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •