I'm using Mingw64 for Windows(of course), and I usually statically link against libwinpthread.a. But I have noticed that there is also a library called libpthread.a (without the win). I can see that they have different sizes, so something must be different. If I create a very simple program with thread library included, I can see that the compiled code also is in different sizes, when I use the tag -libpthread instead of -libwinpthread.
I know that winpthread is using a BSD-license. And in Linux pthread is using the LGPL-license. So can it be something about the license? Maybe libpthread is using LGPL and libwinpthread is using BSD? I don't know.
I hope someone here can help me. Something must be different, because I get different result.
This is embarrassing, but I finally find the difference between libpthread.a and libwinpthread.a. They are 99.9%(you could say 100%) identically.
The only difference is that libwinpthread.a is more compressed. I tried to compile the winpthread-code with make-command. And then I install it with "make install" command. But if I instead install it with "make install-strip" it will install an a-file without symbols table. With the exact same result as the already installed a-files.
So use the tag -lwinpthread if you want to use winpthread(static linking) with no symbols table. If you do want to have the symbols table for winpthread, use the tag -lpthread.
A static library(a-file) is just an archive format(like tar) with o-files inside. To view an a-file you will need for Windows either mingw-w64, cygwin or msys2 or similar. So view an a-file by writing in a terminal: ar -t -file.a
If you want to extract the a-file you can write: ar -x file.a
Now you will have several o-files. You can view the content inside an o-file by writing: nm -C file.o
If you want to diassembler an o-file you can just write: objdump -D file.o
Or write the data to a file: objdump -D file.o > obj_arm.txt
Do that with one o-file from libpthread and one o-file from libwinpthread. And then compare the txt-files with your favorite software. They will be 100% identically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With