What is the equivalent of /usr/lib/ on Windows?

后端 未结 1 2020
忘了有多久
忘了有多久 2021-01-18 01:37

I am creating a cross-platform program that depends on libxml2. I do not want to use a POSIX environment such as Cygwin or MSYS on the Windows port of the app. I am planning

相关标签:
1条回答
  • 2021-01-18 02:01

    The true equivalent of /usr/lib/ in Windows really is %windir%\system32, as it is always the (last) place where Windows looks for DLLs.

    But simply dumping your libraries there is part of why DLL Hell is a thing. This is why the COM system was introduced; if your DLL is a "server module" for COM classes, you can register it (for instance through the regsvr32 utility), after which applications can dynamically link with its served classes through the CoCreateInstance() function. Here, the registry serves the purpose of /usr/lib/, but is completely different.

    In modern Windows versions, the need for explicit registration is no longer needed with (registration-free) side-by-side assemblies. In fact, explicit deregistration of assemblies is sometimes needed to play nice with this new system. In this sense, %SystemRoot%\winsxs is the equivalent of /usr/lib/, but in an even more convoluted way.


    Because of this mess, the answer to your underlying question --- "where should I look for libxml2?" --- is that "you won't find it". Unlike the operating systems that were made for modularity, you usually don't install separate libraries on Windows. If you want to build against libxml2, you either bundle the .lib file with your source, or tell the user to provide it. If you want to deploy a build, you deploy libxml2 along with your application (either statically linked, or as a DLL inside the application directory).

    And even if it were installed system-wide, since libxml2 isn't made with Windows-specific concepts in mind, the only place to find it would be %windir%\system32. Nobody has the gall to place it there, though.


    Note: I'm not very well versed in COM and .NET, so the above might not be completely accurate. If someone wants to improve upon this answer, I'm open to turning this into a community wiki.

    0 讨论(0)
提交回复
热议问题