views:

139

answers:

2

I'm using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies".

I'm looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I statically link it so that it doesn't depend on wsock32.dll?

+1  A: 

wsock32.dll is included with every version of Windows except Windows 95 without networking. You don't need static linking unless your client base consist of very old machines.

ssg
No it is not. If you want to support very old Windows 95 computers, which do not have TCP/IP installed, they also don't have winsock.dll etc. You may still see computers like that in technical or industrial setups.
Lars D
You're wrong. Winsock 1.1 exists since WFW 3.11
ssg
@ssg: You have edited your answer to indicate, that it is not true that winsock can be missing on a Windows PC, and you use wikipedia as a reference. The wikipedia article does not say that all Windows versions install winsock, it merely says that it's in the package. If you had experienced the same as I have, that more than 500 customers call your free hotline to tell you that your application cannot start because winsock.dll is missing, you wouldn't even dare to suggest that it's always present.
Lars D
I didn't have problems with my 500 customers. They said they were happy with built-in winsock 1.1 on windows 95. How about that? Might you be confusing Winsock2 with 1.1 by the way? (because that comes as a separate package)
ssg
Just because it's *available* doesn't mean it's always *installed*.
Warren Young
Warren, Wikipedia article specifically states that Winsock 1.1 is an integral part of Windows 95. And the same article again specifically states that Winsock 2 comes in a separate package for it.
ssg
Yes, and I'm telling you, as maintainer of the Winsock Programmer's FAQ, that a common problem people had when deploying to Windows 95 was that Winsock could be unavailable. **It is an optional install.** This was a time of modems, remember, and Internet penetration even in the US of, what, 10%? Many home Win95 boxes had no Internet at all, so no networking installed. Therefore, no winsock.dll. This is not an opinion. I was there.
Warren Young
Ok it's included in Windows 95 but not installed by default, right?
ssg
On Windows 95, you get a winsock.dll when you install some kind of network. So, if the Win95 OS installer detected a network card it supported out of the box, you could indeed get a "default install" of Win95 with winsock.dll. If not, then not. The point is, you can't count on it being present.
Warren Young
Thanks Warren I edited my answer.
ssg
+3  A: 

The short answer is that you can't. There is no static winsock library, you can only invoke wsock32.dll. Much the same way that you can't statically link to user32 or kernel32. There are things with wsock32.dll internally that are necessarily different on different versions of Windows, and even different service packs on the same versions of Windows, so statically linking would be a bit of a nightmare.

wsock32.dll is present on all versions of Windows that have TCP/IP installed, though, with the same interface, so there wouldn't be any benefit from statically linking anyway.

Gerald
Winsock is not always present. If you want to support very old Windows 95 computers, which do not have TCP/IP installed, they also don't have winsock.dll etc. You may still see computers like that in technical or industrial setups, which need to be serviced. I once had to send a full pallet of CDs to destruction because I assumed that the winsock dll was present on all computers.
Lars D
While this may be true, it's a rather moot point; if the OS does not have TCP/IP installed, nothing you do with Winsock related to TCP/IP will work whether you're using the DLL or not, unless you're installing your own implementation of TCP/IP.
Gerald
If you only use TCP/IP for optional purposes, but the system must be able to run without TCP/IP, too, then it becomes a problem that your application depends on the presence of TCP/IP. Our application was for primary schools, and had worked flawlessly for a long time. Then we added the ability to send/receive information via TCP/IP, and suddenly the support hotline got glowing... the application didn't start because our exe file depended on winsock.dll... we had to scrap all remaining CDs and change the app to load winsock dynamically.
Lars D
Good point, I can see where that would be an issue. It still wouldn't provide a benefit to have a statically linked Winsock though, since it would end up trying to use a non-existent TCP/IP stack, which would crash the system. I will update my answer to reflect this, though.
Gerald