-static-libstdc++ bring in the LIBWINPTHREAD-1.DLL.
Code: Select all
// mutex example
#include <iostream> // std::cout
#include <thread> // std::thread
#include <mutex> // std::mutex
std::mutex mtx; // mutex for critical section
void print_block (int n, char c) {
// critical section (exclusive access to std::cout signaled by locking mtx):
mtx.lock();
for (int i=0; i<n; ++i) { std::cout << c; }
std::cout << '\n';
mtx.unlock();
}
int main ()
{
std::thread th1 (print_block,50,'*');
std::thread th2 (print_block,50,'$');
th1.join();
th2.join();
return 0;
}
i686-w64-mingw32-g++ -std=c++11 test.cpp
LIBWINPTHREAD-1.DLL LIBGCC_S_DW2-1.DLL LIBSTDC++-6.DLL (KERNEL32.DLL MSVCRT.DLL)
i686-w64-mingw32-g++ -std=c++11 -Wl,-Bstatic -lstdc++ -lpthread test.cpp
LIBGCC_S_DW2-1.DLL (KERNEL32.DLL MSVCRT.DLL)
i686-w64-mingw32-g++ -std=c++11 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread test.cpp #<--- here
LIBWINPTHREAD-1.DLL (KERNEL32.DLL MSVCRT.DLL)
i686-w64-mingw32-g++ -std=c++11 -static-libgcc -Wl,-Bstatic -lstdc++ -lpthread test.cpp #<-- and here
(KERNEL32.DLL MSVCRT.DLL)
i686-w64-mingw32-g++ -std=c++11 -static test.cpp
(KERNEL32.DLL MSVCRT.DLL)
i686-w64-mingw32-g++ -std=c++11 -static-libgcc -static-libstdc++ -static test.cpp
(KERNEL32.DLL MSVCRT.DLL)