OpenMP static build (link pthread statically)

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenMP static build (link pthread statically)

adel
Hi,
I am trying to build an OpenMP program statically with MinGW32 4.8.1.
Building it dynamically worked fine and I decided to get rid of dependencies.
objdump -p openmp.exe | grep.exe DLL


DLL Name: KERNEL32.dll 
DLL Name: msvcrt.dll 
DLL Name: msvcrt.dll 
DLL Name: libgcc_s_dw2-1.dll 
DLL Name: libgomp-1.dll 
DLL Name: libstdc++-6.dll 

After building with this command 

ln.exe -s `g++ -print-file-name=libgomp.a`

g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.

I got the following set of DLL's

DLL Name: pthreadGC2.dll 
DLL Name: KERNEL32.dll 
DLL Name: msvcrt.dll 
DLL Name: msvcrt.dll 

At this point I can't get rid of pthreadGC2.dll. Linking statically either makes no effect (.exe file still needs pthreadGC2.dll) or fails with errors:

ln.exe -s `g++ -print-file-name=libgomp.a`

g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.

C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xbfe): undefined reference to `_imp__pthread_attr_init'
C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xc13): undefined reference to _imp__pthread_attr_setdetachstate'
C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0x3c): undefined reference to '_imp__pthread_attr_setstacksize'

After searching through the mailing list I have come across several possible solutions, but the treads are rather old.
My questions are:

1. Do I still need to somehow compile pthread statically? And libpthreadGC2.a is not actually a static library? If so, is there an updated instruction?

2. Are there any other libraries I need to actually make this work? In Linux it is said that pthread needs to be included with libc.a and won't link without it.

Thank you in advance. 


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Earnie Boyd
> From: Адель Хафизова


> At this point I can't get rid of pthreadGC2.dll. Linking statically either makes no
> effect (.exe file still needs pthreadGC2.dll) or fails with errors:
> ln.exe -s `g++ -print-file-name=libgomp.a`
> g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.
> C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xbfe): undefined
> reference to `_imp__pthread_attr_init'
> C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xc13): undefined
> reference to _imp__pthread_attr_setdetachstate'
> C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0x3c): undefined reference
> to '_imp__pthread_attr_setstacksize'
> After searching through the mailing list I have come across several possible
> solutions, but the treads are rather old.
> My questions are:
> 1. Do I still need to somehow compile pthread statically? And libpthreadGC2.a is
> not actually a static library? If so, is there an updated instruction?
> 2. Are there any other libraries I need to actually make this work? In Linux it is
> said that pthread needs to be included with libc.a and won't link without it.
> Thank you in advance.

The design of the pthread library is such that it must be dynamic.  It is impossible to do otherwise.  The alternative is to use the Windows methods for threading in the package you're building instead of relying on POSIX threading model.

--
Earnie


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Eli Zaretskii
> From: "Earnie" <[hidden email]>
> Date: Tue, 23 Jun 2015 14:00:16 -0400
>
> > At this point I can't get rid of pthreadGC2.dll. Linking statically either makes no
> > effect (.exe file still needs pthreadGC2.dll) or fails with errors:
> > ln.exe -s `g++ -print-file-name=libgomp.a`
> > g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.
> > C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xbfe): undefined
> > reference to `_imp__pthread_attr_init'
> > C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0xc13): undefined
> > reference to _imp__pthread_attr_setdetachstate'
> > C:\for_openmp_test/libgomp.a(env.o):(.text.startup+0x3c): undefined reference
> > to '_imp__pthread_attr_setstacksize'
> > After searching through the mailing list I have come across several possible
> > solutions, but the treads are rather old.
> > My questions are:
> > 1. Do I still need to somehow compile pthread statically? And libpthreadGC2.a is
> > not actually a static library? If so, is there an updated instruction?
> > 2. Are there any other libraries I need to actually make this work? In Linux it is
> > said that pthread needs to be included with libc.a and won't link without it.
> > Thank you in advance.
>
> The design of the pthread library is such that it must be dynamic.  It is impossible to do otherwise.  The alternative is to use the Windows methods for threading in the package you're building instead of relying on POSIX threading model.

Based on the error messages, I understand that it's libgomp that was
configured to use pthreads, and is the reason why pthreadGC2.dll is
needed, is that right?  IOW, to avoid this problem, one needs to
rebuild libgomp, configuring it to use win32 threads instead (assuming
libgomp supports such a configuration), correct?

Are there any other GCC components that depend on pthreads?

TIA

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

John E. / TDM
On 6/23/2015 12:28 PM, Eli Zaretskii wrote:
>> From: "Earnie" <[hidden email]>
>> Date: Tue, 23 Jun 2015 14:00:16 -0400
>>
>> The design of the pthread library is such that it must be dynamic.  It is impossible to do otherwise.

Used to be the case, but not anymore - both the pthreads-win32 and the
winpthreads wrapper libraries can be built statically and will still
perform all necessary startup task via special callbacks.

Static pthreads will mean you can't safely share pthreads handles across
the DLL boundary, but that won't matter to the OP who is trying to get
rid of all DLL dependencies.

>>    The alternative is to use the Windows methods for threading in the package you're building instead of relying on POSIX threading model.
> Based on the error messages, I understand that it's libgomp that was
> configured to use pthreads, and is the reason why pthreadGC2.dll is
> needed, is that right?  IOW, to avoid this problem, one needs to
> rebuild libgomp, configuring it to use win32 threads instead (assuming
> libgomp supports such a configuration), correct?

Sadly, libgomp won't compile without pthreads.

> Are there any other GCC components that depend on pthreads?

The C++11 threading/synchronization features (std::thread and friends)
require pthreads as well -- for a default native build with the win32
threading model, GCC will still successfully build but these features
will be unavailable.

-John E. / TDM

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Sergio NNX
In reply to this post by adel
> 1. Do I still need to somehow compile pthread statically? And libpthreadGC2.a is not actually a static library? If so, is there an updated
> instruction?

We have been using pthreads statically for some time now without issues. We have built several large apps from source and haven't had any problems so far. Perhaps you should give it a go.

Cheers.


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Eli Zaretskii
In reply to this post by John E. / TDM
> From: "John E. / TDM" <[hidden email]>
> Date: Tue, 23 Jun 2015 15:42:28 -0600
>
> > Based on the error messages, I understand that it's libgomp that was
> > configured to use pthreads, and is the reason why pthreadGC2.dll is
> > needed, is that right?  IOW, to avoid this problem, one needs to
> > rebuild libgomp, configuring it to use win32 threads instead (assuming
> > libgomp supports such a configuration), correct?
>
> Sadly, libgomp won't compile without pthreads.

Sad indeed.

> > Are there any other GCC components that depend on pthreads?
>
> The C++11 threading/synchronization features (std::thread and friends)
> require pthreads as well -- for a default native build with the win32
> threading model, GCC will still successfully build but these features
> will be unavailable.

I know, but that's irrelevant here, since mingw.org's GCC is built
with native threads (and thus doesn't support std::thread).

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Eli Zaretskii
> Date: Wed, 24 Jun 2015 05:45:45 +0300
> From: Eli Zaretskii <[hidden email]>
>
> > From: "John E. / TDM" <[hidden email]>
> > Date: Tue, 23 Jun 2015 15:42:28 -0600
> >
> > > Based on the error messages, I understand that it's libgomp that was
> > > configured to use pthreads, and is the reason why pthreadGC2.dll is
> > > needed, is that right?  IOW, to avoid this problem, one needs to
> > > rebuild libgomp, configuring it to use win32 threads instead (assuming
> > > libgomp supports such a configuration), correct?
> >
> > Sadly, libgomp won't compile without pthreads.
>
> Sad indeed.

Btw, which parts of C++ need libgomp?

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

John E. / TDM
On 6/24/2015 8:23 AM, Eli Zaretskii wrote:
> Btw, which parts of C++ need libgomp?

To my knowledge, none. If a GCC user specifies -fopenmp (to enable
support of OMP directives), it understandably creates a dependency on
libgomp (which depends on pthreads), but if -fopenmp is not used I don't
think there's any libgomp or pthreads dependency.

-John E. / TDM

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Eli Zaretskii
> From: "John E. / TDM" <[hidden email]>
> Date: Wed, 24 Jun 2015 09:40:39 -0600
>
> On 6/24/2015 8:23 AM, Eli Zaretskii wrote:
> > Btw, which parts of C++ need libgomp?
>
> To my knowledge, none. If a GCC user specifies -fopenmp (to enable
> support of OMP directives), it understandably creates a dependency on
> libgomp (which depends on pthreads), but if -fopenmp is not used I don't
> think there's any libgomp or pthreads dependency.

Ah, OK.  So the only reason for dependency on pthreadGC2.dll in this
case was that -fopenmp switch, and nothing else.

Thanks.

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

adel
In reply to this post by Sergio NNX
Thanks everyone for the discussion.
Still there are some issues I misunderstand.
I tried building pthreads statically with
make clean GC-static
The result was the same: libpthread.a produced with this build when linked without -static gives pthreadGC2.dll dependency, with -static option it doesn't link. Could you please give a general overview what to do to make this work?
Are there any other possible solutions except taking this .dll to another computer (if I got it correctly, I can't just use win32 threads)?

2015-06-24 2:10 GMT+04:00 Sergio NNX <[hidden email]>:
> 1. Do I still need to somehow compile pthread statically? And libpthreadGC2.a is not actually a static library? If so, is there an updated
> instruction?

We have been using pthreads statically for some time now without issues. We have built several large apps from source and haven't had any problems so far. Perhaps you should give it a go.

Cheers.




--
Best regards, 
Adel Khafizova

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically)

Eli Zaretskii
> Date: Thu, 25 Jun 2015 15:08:48 +0400
> From: Адель Хафизова
> <[hidden email]>
>
> I tried building pthreads statically with
> make clean GC-static
> The result was the same: libpthread.a produced with this build when linked
> without -static gives pthreadGC2.dll dependency, with -static option it doesn't
> link. Could you please give a general overview what to do to make this work?

Please provide the details regarding "with -static option it doesn't
link".  What happens if you try?  If there are error messages, please
show them.


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), any update?

adel
Unfortunately, there are no updates, there are still undefined references errors which were described in the very first post. 

понедельник, 29 июня 2015 г. пользователь Sergio NNX написал:
Any update on this matter?

> Date: Thu, 25 Jun 2015 17:36:39 +0300

> From: <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;eliz@gnu.org&#39;);" target="_blank">eliz@...
> To: <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;mingw-users@lists.sourceforge.net&#39;);" target="_blank">mingw-users@...
> Subject: Re: [Mingw-users] OpenMP static build (link pthread statically)
>
> > Date: Thu, 25 Jun 2015 15:08:48 +0400
> > From: Адель Хафизова
> > <<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;adelkhafizova@gmail.com&#39;);" target="_blank">adelkhafizova@...>
> >
> > I tried building pthreads statically with
> > make clean GC-static
> > The result was the same: libpthread.a produced with this build when linked
> > without -static gives pthreadGC2.dll dependency, with -static option it doesn't
> > link. Could you please give a general overview what to do to make this work?
>
> Please provide the details regarding "with -static option it doesn't
> link". What happens if you try? If there are error messages, please
> show them.


--
С уважением, 
Адель Хафизова


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

OpenMP static build (link pthread statically), what's the alternative?

adel
I apologise very much for the late reply, I didn't have much access to the computer lately.
So, one more time.
I tried to create an .exe without any additional DLL dependencies so that OpenMP program could be launched on other Windows machines. To do so I compiled pthread statically with command:
make clean GC-static
Nevertheless, it produced libpthread-static.a, which size is 95 KB (to my mind, it is too small to be a full static library, it seems to be a wrapper, which calls in turn pthreadGC2.dll). 
The problem is just the same with undefined references to _imp__* while compiling via

ln.exe -s `g++ -print-file-name=libgomp.a`

g++ openmp.cpp -o openmp.exe -static -static-libgcc -static-libstdc++ -fopenmp -L.

Doing this

ln.exe -s `g++ -print-file-name=libgomp.a`

g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.

gives openmp.exe which is dependent from pthreadGC2.dll. The static library corresponding to pthreadGC2.dll should be libpthread.a or libpthread-static.a or something like that, but all attempts to create a truly static library end up with having the little wrapper library (as I suppose) which continues to call pthreadGC2.dll.

I definitely misunderstand something but still can't figure out what.

The source code is nothing special, just an example from the Internet

http://pastebin.com/r4pU7tsG

2015-07-02 3:58 GMT+04:00 Sergio NNX <<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;sfhacker@hotmail.com&#39;);" target="_blank">sfhacker@...>:
> Unfortunately, there are no updates, there are still undefined references errors which were described in
> the very first post.
I see. What's the alternative then?
I could have a 'closer' look at it. Can you provide a simple test source code in order to reproduce the problem?

Cheers.



--
Best regards,
Adel Khafizova


--
Best regards,
Adel Khafizova


------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), what's the alternative?

Keith Marshall-3
On 25/07/15 23:45, Адель Хафизова wrote:
> I tried to create an .exe without any additional DLL dependencies so that
> OpenMP program could be launched on other Windows machines. To do so I
> compiled pthread statically with command:
>
>   make clean GC-static
>
> Nevertheless, it produced libpthread-static.a, which size is 95 KB (to my
> mind, it is too small to be a full static library,

Hmm. When I do this, using my cross-hosted tool chain:

  $ make clean CROSS=mingw32 GC-static

I get a library called "libpthreadGC2.a", with a size of 102K.  I don't
know if its size really is unrealistically small, but it does appear to
be a static library.  (FWIW, if I do:

 $ make clean CROSS=mingw32 GC

instead, "libpthreadGC2.a" is overwritten by a smaller 92K variant,
which *is* an import library for "pthreadGC2.dll".  IMO, this is a build
system bug -- when the build system is capable of producing both static
and dynamic builds, they should be differentiated by calling the import
library "libpthreadGC2.dll.a"; bad pthreads-w32).

> it seems to be a wrapper, which calls in turn pthreadGC2.dll).

Are you sure about this?  What does "dlltool -I lib..." say about it?
What set of symbols does "nm -A lib..." list?

> The problem is just the same with undefined references to _imp__*

Did you also build your application with "-DPTW32_STATIC_LIB"?  Was the
libgomp.a, which you appear to be using, also built with this?

Just a final thought: why do so many Win32 application developers invest
so much time and effort into elimination of DLL dependencies?
Especially when the DLLs in question are freely redistributable?

--
Regards,
Keith.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), what's the alternative?

Eli Zaretskii
> From: Keith Marshall <[hidden email]>
> Date: Sun, 26 Jul 2015 12:17:46 +0100
>
> Just a final thought: why do so many Win32 application developers invest
> so much time and effort into elimination of DLL dependencies?
> Especially when the DLLs in question are freely redistributable?

I can only speak for myself: because this leads to DLL hell,
especially when the DLLs in question come with the compiler, and
therefore chances are the next version of the compiler will bring a
different one.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), what's the alternative?

Keith Marshall-3
On 26/07/15 15:52, Eli Zaretskii wrote:
>> From: Keith Marshall <[hidden email]>
>> Date: Sun, 26 Jul 2015 12:17:46 +0100
>>
>> Just a final thought: why do so many Win32 application developers invest
>> so much time and effort into elimination of DLL dependencies?
>> Especially when the DLLs in question are freely redistributable?
>
> I can only speak for myself: because this leads to DLL hell,

Agreed, it may do so, but it shouldn't if the DLL's in question are
properly versioned, and especially if they are installed locally to the
directory containing the dependent executable ... unless, of course,
that directory also contains other executables with identically named,
yet incompatible -- and thus, by definition, improperly versioned --
DLLs.  (I'm thinking that a rebuild of the pthreads-w32 DLLs, linked
against mingwrt-3.21.1 with its "struct timespec" definition, will
introduce a binary incompatibility with previous releases, and thus,
will necessitate an interface version bump).

> especially when the DLLs in question come with the compiler, and
> therefore chances are the next version of the compiler will bring a
> different one.

Once again, if those DLLs are properly versioned, the latest with the
appropriate interface version should suffice in all cases.

--
Regards,
Keith.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), what's the alternative?

Eli Zaretskii
> From: Keith Marshall <[hidden email]>
> Date: Sun, 26 Jul 2015 18:55:48 +0100
>
> On 26/07/15 15:52, Eli Zaretskii wrote:
> >> From: Keith Marshall <[hidden email]>
> >> Date: Sun, 26 Jul 2015 12:17:46 +0100
> >>
> >> Just a final thought: why do so many Win32 application developers invest
> >> so much time and effort into elimination of DLL dependencies?
> >> Especially when the DLLs in question are freely redistributable?
> >
> > I can only speak for myself: because this leads to DLL hell,
>
> Agreed, it may do so, but it shouldn't if the DLL's in question are
> properly versioned

The problem is, there's no way of knowing whether they are properly
versioned.  As long as two DLLs have different time stamps and sizes,
you are never sure.  Just see how many different copies of
libgcc_s_dw2-1.dll you find on any given Windows machine.  How is
J.R. Hacker to know whether they are all backward-compatible?

> and especially if they are installed locally to the
> directory containing the dependent executable

This leads to a very long PATH, where each package has its own bin/
directory.  By contrast, I use a single Posix-style tree, where bin/
has all the binaries and DLLs, lib/ all the libraries, share/ all the
docs and auxiliary files, etc.  It is imperative with this scheme to
have DLLs that are either compatible or have different names (a.k.a.
"properly versioned").  Since I build most of my package myself, I can
arrange for that, and that is why all the packages on ezwinports have
exactly the same identical DLLs in them -- you can overwrite them or
not overwrite, the result will be the same.  But I cannot do that with
DLLs that come with the compiler and other development tools I don't
provide, because I don't want to ruin someone's toolchain by
overwriting their libgcc_s_dw2-1.dll or pthreadGC2.dll with my
versions.  So I try very hard not to have these dependencies in the
binaries I offer for download.  I even went as far lately as providing
C++ bindings for some packages as only static libraries, because I
couldn't get rid of the libstdc++ DLL dependency in the shared library
versions.

> (I'm thinking that a rebuild of the pthreads-w32 DLLs, linked
> against mingwrt-3.21.1 with its "struct timespec" definition, will
> introduce a binary incompatibility with previous releases, and thus,
> will necessitate an interface version bump).

But if someone rebuilds the package with an incompatible runtime, and
doesn't override the names recorded in the package's configury, they
are almost certainly going to produce the same foo-NN.dll, with the
same NN version number, and with subtly incompatible interfaces.

> > especially when the DLLs in question come with the compiler, and
> > therefore chances are the next version of the compiler will bring a
> > different one.
>
> Once again, if those DLLs are properly versioned, the latest with the
> appropriate interface version should suffice in all cases.

Yes. _If_ they are properly versioned.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: OpenMP static build (link pthread statically), what's the alternative?

Sergio NNX
In reply to this post by adel
> The problem is just the same with undefined references to _imp__* while compiling via

> ln.exe -s `g++ -print-file-name=libgomp.a`

> g++ openmp.cpp -o openmp.exe -static -static-libgcc -static-libstdc++ -fopenmp -L.

> Doing this

>ln.exe -s `g++ -print-file-name=libgomp.a`

>g++ openmp.cpp -o openmp.exe -static-libgcc -static-libstdc++ -fopenmp -L.

> gives openmp.exe which is dependent from pthreadGC2.dll. The static library corresponding to pthreadGC2.dll

I'm far from an expert here but apparently someone has built either GCC or libgomp (or both) in 'shared' mode and now the OP is banging his/her head against the wall since there is no way the OP could revert this 'shared' mode.

To my mind, this issue has nothing to do with pthreads library, but GCC or gomp (or both). Take a look at this:

c:/mingw/bin/../lib/gcc/mingw32/4.7.2\libgomp.a(parallel.o):(.text+0x66): undefi
ned reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2\libgomp.a(parallel.o):(.text+0x86): undefi
ned reference to `_imp__pthread_mutex_unlock'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2\libgomp.a(parallel.o):(.text+0x14f): undef
ined reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2\libgomp.a(parallel.o):(.text+0x169): undef
ined reference to `_imp__pthread_mutex_unlock'

Have fun.


------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe