【发布时间】:2012-11-25 22:50:34
【问题描述】:
我从这里使用 mingw:http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.2/32-bit/threads-posix/sjlj/x32-4.7.2-release-posix-sjlj-rev2.7z/download
我已经成功地使用-static-libgcc -static-libstdc++ 参数静态链接libstdc++-6.dll 和libgcc_s_sjlj-1.dll,但我找不到使用libwinpthread-1.dll 执行相同操作的命令。
【问题讨论】:
-
只是为了技术上的清晰,如果你是静态链接,你没有链接到 DLL。
libgcc和libstdc++库有静态和非静态 (DLL) 版本,如果您静态链接,则不会链接到 DLL。您希望静态链接到pthreads库,而不是libwinpthread-1.dll(因为您不能静态链接到动态库......这违背了动态库的目的)。 -
我得到:
c++: error: unrecognized command line option '-static-pthreads',和winpthreads一样 -
小窍门:mingw 自带的 libwinpthread-1.dll 和网上流传的不一样。使用错误的会导致无限递归的 DLL 调用(根据 Dependency walker),然后是堆栈溢出。
-
只需链接
-l:libwinpthread.a
标签: c++ mingw static-linking