Hi all,
I have found something that is somehow common within my google research but I could not find any topic that solves the issue. Except perhaps this one (in French) http://www.developpez.net/forums/d787443/c-cpp/c/dll-manquante-pthread-lib/#... but I do not understand how he really achieved it.
In order to reproduce the issue I used the hello world from wikipedia: http://en.wikipedia.org/wiki/OpenMP#Fortran_77 I named it omp.F
Compiled with: gfortran -o omp omp.F -fopenmp -lpthread This works: $ ./omp HELLO WORLD FROM THREAD 0 HELLO WORLD FROM THREAD 3 HELLO WORLD FROM THREAD 2 HELLO WORLD FROM THREAD 1 THERE ARE 4 THREADS
Then I tried to compile it for Windows 64 and 32 bits but it fails when running. Compiled with: x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 or x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread
When running it under an XP computer (32 or 64 bits depending on the binary) it always fails with: pthreadGC2.dll was not found. I really need this in static so adding the flag -static should have solved and used the .a file, isn't it?
On my computer I have the mingw-pthread package installed: mingw32-pthreads-2.8.0-14.cvs20110104.fc15_cross.noarch mingw64-pthreads-2.8.0-14.cvs20110104.fc15_cross.noarch
Also: # locate *pthreadGC2* /usr/i686-w64-mingw32/sys-root/mingw/bin/pthreadGC2.dll /usr/i686-w64-mingw32/sys-root/mingw/lib/libpthreadGC2.a /usr/x86_64-w64-mingw32/sys-root/mingw/bin/pthreadGC2.dll /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libpthreadGC2.a
I hope there is a solution, Fabien
Archambault Fabien schreef op ma 30-05-2011 om 16:36 [+0200]:
Then I tried to compile it for Windows 64 and 32 bits but it fails when running. Compiled with: x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 or x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread
When running it under an XP computer (32 or 64 bits depending on the binary) it always fails with: pthreadGC2.dll was not found. I really need this in static so adding the flag -static should have solved and used the .a file, isn't it?
No, when you use -lpthread (and there are both a static and a shared library available) then the binary will be linked against the shared library. If you really want to link against a static lib then you have to refer to it using the full path (and without the '-l' flag), so you'll get something like:
x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp /usr/x86_64-w64-mingw32/sys-root/mingw-lib/libpthreadGC2.a
However, there's another catch here. There is no mingw32/64-pthreads-static package available at the moment..so the above command won't work. If you want to run your application you need to bundle the pthread dll for now.
Kind regards,
Erik van Pienbroek
On 05/30/2011 08:54 PM, Erik van Pienbroek wrote:
Archambault Fabien schreef op ma 30-05-2011 om 16:36 [+0200]:
Then I tried to compile it for Windows 64 and 32 bits but it fails when running. Compiled with: x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread -lpthreadGC2 or x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread i686-w64-mingw32-gfortran -o omp omp.F -static -fopenmp -lpthread
When running it under an XP computer (32 or 64 bits depending on the binary) it always fails with: pthreadGC2.dll was not found. I really need this in static so adding the flag -static should have solved and used the .a file, isn't it?
No, when you use -lpthread (and there are both a static and a shared library available) then the binary will be linked against the shared library. If you really want to link against a static lib then you have to refer to it using the full path (and without the '-l' flag), so you'll get something like:
x86_64-w64-mingw32-gfortran -o omp omp.F -static -fopenmp /usr/x86_64-w64-mingw32/sys-root/mingw-lib/libpthreadGC2.a
However, there's another catch here. There is no mingw32/64-pthreads-static package available at the moment..so the above command won't work. If you want to run your application you need to bundle the pthread dll for now.
Kind regards,
Erik van Pienbroek
Hi,
thanks for this answer that explains in a very clear way why it did not work. I believe I will have to bundle the library for the moment as you said. I will also try to recompile the RPM to try if it is possible to build the static lib but with few hope to get something working...
Really thanks for all your explanations, Fabien