Include an external library in my .lib file

I'm using MS Visual 2010 and I've created a static library (.lib). Now, my library uses #include <winsock2.h> in one of the header (.hpp) files. This means that I need to link ws2_32.lib when I compile.

Unfortunately, I can't figure out how to link ws_32.lib to my project when the configuration is set to "Static Library". As a result, I need to link both my .lib file and ws2_32.lib in any projects that use my static library as seen below:

1
2
$(SolutionDir)$(Configuration)\MyLibrary.lib
ws2_32.lib


This is an acceptable temporary solution, however I'd like to somehow link ws_32.lib in my library so that a user does not need to link to both libraries on their side. Does anyone know how to do this?

Help!
closed account (S6k9GNh0)
I've gone through this. Most people just say, "Just do what works here" because doing otherwise is simply a hassle. In reality, copying stub symbols from ws2_32.lib into your library is inefficient anyways.
I'm not quite sure what you mean. Is including winsock2.h the same as copying stub symbols? If so, what would you recommend as an alternative?

Edit: Keywords are acceptable. That'll give me something that I can at least search.
Last edited on
I found the solution:

In my static library project I had to go to:

Menu: Project > Properties > Configuration Properties > Librarian > General > Additional Dependencies > Edit

In this box I had to add ws2_32.lib.

Ta da! ws2_32.lib is now contained in my lib so the end user does not need to link this themselves. Horray!
You should be aware that doing that has legal implications when it comes to distributing your code binary libraries. Since you are linking against a library everyone with a Windows machine has, it seems to me that you are spending too much time worrying about it... IMHO.
Last edited on
Topic archived. No new replies allowed.