On 2017/1/21 6:01, Computer Jock wrote: > I hope I know what I'm talking about here... > > Sometimes (probably with g++) when attempting to create a 64-bit DLL > with only windows dependencies one gets a reference to: > > libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll > > Googling for solutions finds quite a few people having the same problem. > > Many suggest using: > > g++ -shared ... > -static-libgcc -static-libstdc++ > -Wl,-Bstatic > -lstdc++ > -lpthread > -Wl,-Bdynamic > > That works for some links but not for others. > > I ran across this debian bug report from 2014: > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=748353 > > It suggests that it would be possible to avoid the reference to > libwinpthread-1.dll in favor of the default windows threading library. > That is not possible as long as you are using a GCC with the `posix` thread model. You have to build one yourself since MSYS2 does not provide such a toolchain AFAIK.
> Two related questions: > > 1) Is there a way to ensure statically linking -lpthread and avoid the > reference to libwinpthread-1.dll ? Yes. Just delete the file `libwinpthread.dll.a`. One more word: `-lpthread` is basically *wrong*. To compile and link with pthread, use `-pthread` (no `l` there). > 2) Would the fix (I assume they fixed it for debian) work for the msys2 > 64-bit gcc? Yes. GCC prefers dynamic libraries unless `-static` is given. When a dynamic library isn't available it looks for the corresponding static library instead. You do have `libwinpthread.a`, no? -- Best regards, LH_Mouse ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Msys2-users mailing list Msys2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/msys2-users