Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static linking with libwinpthread

I try to build program with static linked toolchain libraries. I pass:

LDFLAGS="-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic -static-libgcc -static-libstdc++"

but program linked with shared libwinpthread-1.dll.

What I doing wrong?

Only way when I got static linked libwinpthreads is pass -static to LDFLAGS. But it break build programs with plugin system.

I use mingw-w64 + GCC-4.7.2 from the MinGW-builds project: http://sourceforge.net/projects/mingwbuilds/

like image 219
niXman Avatar asked Feb 02 '13 19:02

niXman


People also ask

What does static linking do?

Static linking increases the file size of your program, and it may increase the code size in memory if other applications, or other copies of your application, are running on the system. This option forces the linker to place the library procedures your program references into the program's object file.

How do I fix Libwinpthread 1 DLL is missing?

Reinstalling the program may fix this problem. libwinpthread-1. dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vender for support.

What does it mean to be statically linked?

Static linking means that the code for all routines called by your program becomes part of the executable file. Statically linked programs can be moved to run on systems without the XL Fortran runtime libraries.


1 Answers

Try this:

-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic

Notice the -lstdc++ before -lpthread. It worked for me.

Make sure to add this to the very end of your g++ command line.

like image 140
Star Brilliant Avatar answered Sep 20 '22 08:09

Star Brilliant