You might run into a problem using only the static libwinpthread on some packages, i speak from experience since
im using a method similar to the suggested one. The problem is that some shared libraries linked to the static libwinpthread.a library will throw a multiple definition error if the winpthread functions are allready referenced in those libraries. To get around that use -Wl,--exclude-libs,libpthread.a in LDFLAGS and things should work again. You could also use -Wl,--allow-multiple-definition but its not recomended since i seen examples of it breaking other stuff. Den 21-01-2017 kl. 03:58 skrev lhmouse: > 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? > ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/msys2-users
