您可以使用 vcpkg here。这是 C++ 的 Windows 包管理器。
它支持 pthread 构建以及其他开源库。
我想使用静态 pthread 库。
当我下载 pthread 时,我得到了 dll(pthread.dll) 并导入 lib(pthread.lib),即我不能只使用 pthread.lib 我必须使用 pthread.dll 文件。
所以我使用 vcpkg 构建了静态库。我可以在没有任何 dll 依赖项的情况下使用它
使用“vcpkg”,您可以构建静态库和动态库
您可以使用以下步骤
下面我添加了所有 DLL (x86|x64) 和 LIB (x86|x64) 案例的步骤。您可以根据需要构建它。
从git目录vcpkg git repo克隆vcpkg
从您克隆 vcpkg 的目录运行以下命令 - 这将安装 vcpkg
bootstrap - vcpkg.bat
通过运行以下命令检查库的可用性
vcpkg search pthread
下面会显示结果
mbedtls[pthreads] Multi-threading support
pthread 3.0.0 empty package, linking to other port
pthreads 3.0.0-6 pthreads for windows
如您所见,它支持 Windows 的 pthread
1.使用导入库(DLL)构建动态库
构建 x86 DLL
vcpkg install pthreads:x86-windows
这将在 .\vcpkg\installed\x86-windows 中构建 dll 和导入库
这里复制 lib 和 include 就可以使用了
构建 x64 DLL
vcpkg install pthreads:x64-windows
这将在 .\vcpkg\installed\x64-windows 中构建 dll 和导入库
在此处复制 lib 和 include 文件夹。
2。构建静态库 (LIB)
构建 x86 LIB
vcpkg install pthreads:x86-windows-static
这将在 .\vcpkg\installed\x86-windows-static 中构建 dll 和导入库
从这里复制 lib 和 include 你可以使用它们
构建 x64 LIB
vcpkg install pthreads:x64-windows-static
这将在 .\vcpkg\installed\x64-windows-static 中构建 dll 和导入库
从这里复制 lib 和 include 文件夹。
注意:尝试以管理员权限使用