Runtime DLL linking (winsock)

Started by
1 comment, last by DaBono 16 years, 11 months ago
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
-------------------------------------Physics Labhttp://www.physics-lab.netC++ Labhttp://cpp.physics-lab.net
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")
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?

This topic is closed to new replies.

Advertisement