Jump to content
  • Advertisement
Sign in to follow this  
Gavinl

Runtime DLL linking (winsock)

This topic is 4056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a question about linking a DLL file during runtime. What I am doing is creating an IRC client class, basically a single class file that can connect to and IRC server and send/recieve messages from it. What I want to be able to do is just do: #include <myIRCclass.h> and be set to use the class. The problem is that since it uses winsock I have to link the winsock.a file (i'm using devC++ IDE) or it will give me "Undefined reference to <winsock function>" error Is there any way i can use the winsock functions without having to link that .a file? Some how link winsock.dll during runtime in my header file, and be done with it? Any help would be appreciated. Thank you Gavin

Share this post


Link to post
Share on other sites
Advertisement
Look into LoadLibrary and GetProcAddress. You should be able to load the winsock DLL at runtime that way.

However, you might be just as easy using a pragma to add the library. In MSVC (I know you're using Dev-CPP, there's probably an equivalent) you put this in a source/header file:
#pragma comment(lib, "ws2_32.lib")

Share this post


Link to post
Share on other sites
Quote:
Original post by Gavinl
The problem is that since it uses winsock I have to link the winsock.a file.
Is there any way i can use the winsock functions without having to link that .a file?

What's the problem with just linking to the .a-file?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!