MinGW/GCC based on MSVCR100 Runtime

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

MinGW/GCC based on MSVCR100 Runtime

Orgulut
Hello,

I need to use DLLs generated by MinGW/GCC 4.7.0 in Visual Studio 2010 application. 
As expected, different runtimes living in one process lead to unpredictable results. 

In connection with this, I would greatly appreciate any help on how to build MinGW/GCC (4.7.0) with initial support of MSVCR100 runtime (instead of msvcr.dll).

Now, using "specs" file I can force GCC to produce DLL with MSVCR100.
However, I have to recompile GCC from the scratch, so that  GCC-specific libraries also rely on MSVCR100. 
(I use them in my code, like libquadmath, etc.).

Any pointers/references/step-by-step guides on how to re-compile MinGW/GCC 4.7.x with MSVCR100 would be much appreciated.
(Or at least detailed manual on how to build GCC for MinGW.)

Thank you in advance.
Pavel


 


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Earnie Boyd
On Tue, Oct 16, 2012 at 4:54 AM, Pavel Holoborodko wrote:
> Hello,
>
> I need to use DLLs generated by MinGW/GCC 4.7.0 in Visual Studio 2010
> application.
> As expected, different runtimes living in one process lead to unpredictable
> results.
>

And this result is documented on MSDN.

> In connection with this, I would greatly appreciate any help on how to build
> MinGW/GCC (4.7.0) with initial support of MSVCR100 runtime (instead of
> msvcr.dll).
>

Does LIBS=-lmsvcr100 not work for you?

> Now, using "specs" file I can force GCC to produce DLL with MSVCR100.
> However, I have to recompile GCC from the scratch, so that  GCC-specific
> libraries also rely on MSVCR100.
> (I use them in my code, like libquadmath, etc.).
>

No you do not need build GCC just for a new specs file.  You can state
the specs file location on the command line (-specs=<file>) or you can
place the specs file where GCC expects to find it.  For MinGW assuming
you have installed in C:\MinGW, you are using MSYS with C:/MinGW
mapped to /mingw and your GCC version is 4.7.0 then you place the
specs in the /mingw/lib/gcc/mingw32/4.7.0 directory.

To get the original specs file you can use -dumpspecs option to gcc
and redirect the output to a file.

> Any pointers/references/step-by-step guides on how to re-compile MinGW/GCC
> 4.7.x with MSVCR100 would be much appreciated.
> (Or at least detailed manual on how to build GCC for MinGW.)
>

You don't need to so I won't give those here.  The source package
comes with a build process but there are a number of dependency
libraries you'll need.  We supply those as well, you just need to
install the -dev package for them.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Orgulut
Thank you for your answer.

My problem is that in my code I use standard libraries from GCC (libquadmath, libgcc, etc), which were compiled together with GCC with link to MSVCR.
I guess "specs" file cannot save the situation. Full re-compilation is needed (?).

Sorry for unclear explanation in my first message. I did test "specs" before writing to the mail-list.

On Tue, Oct 16, 2012 at 8:50 PM, Earnie Boyd <[hidden email]> wrote:
On Tue, Oct 16, 2012 at 4:54 AM, Pavel Holoborodko wrote:
> Hello,
>
> I need to use DLLs generated by MinGW/GCC 4.7.0 in Visual Studio 2010
> application.
> As expected, different runtimes living in one process lead to unpredictable
> results.
>

And this result is documented on MSDN.

> In connection with this, I would greatly appreciate any help on how to build
> MinGW/GCC (4.7.0) with initial support of MSVCR100 runtime (instead of
> msvcr.dll).
>

Does LIBS=-lmsvcr100 not work for you?

> Now, using "specs" file I can force GCC to produce DLL with MSVCR100.
> However, I have to recompile GCC from the scratch, so that  GCC-specific
> libraries also rely on MSVCR100.
> (I use them in my code, like libquadmath, etc.).
>

No you do not need build GCC just for a new specs file.  You can state
the specs file location on the command line (-specs=<file>) or you can
place the specs file where GCC expects to find it.  For MinGW assuming
you have installed in C:\MinGW, you are using MSYS with C:/MinGW
mapped to /mingw and your GCC version is 4.7.0 then you place the
specs in the /mingw/lib/gcc/mingw32/4.7.0 directory.

To get the original specs file you can use -dumpspecs option to gcc
and redirect the output to a file.

> Any pointers/references/step-by-step guides on how to re-compile MinGW/GCC
> 4.7.x with MSVCR100 would be much appreciated.
> (Or at least detailed manual on how to build GCC for MinGW.)
>

You don't need to so I won't give those here.  The source package
comes with a build process but there are a number of dependency
libraries you'll need.  We supply those as well, you just need to
install the -dev package for them.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Earnie Boyd
On Tue, Oct 16, 2012 at 8:44 AM, Pavel Holoborodko wrote:

PLEASE DO NOT TOP POST.

> Thank you for your answer.
>
> My problem is that in my code I use standard libraries from GCC
> (libquadmath, libgcc, etc), which were compiled together with GCC with link
> to MSVCR.
> I guess "specs" file cannot save the situation. Full re-compilation is
> needed (?).
>
> Sorry for unclear explanation in my first message. I did test "specs" before
> writing to the mail-list.

So you're wanting the dependent DLL to use MSVCR100?  Have you
considered using the static libraries instead?

As I stated in my last mail there is a build process embedded in the
delivered source.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Orgulut

So you're wanting the dependent DLL to use MSVCR100?  Have you
considered using the static libraries instead?

Ah, yes, exactly, this solves the problem with different runtimes. Thank you!

However, unfortunately I still get the same unstable results using DLLs compiled by MinGW in Visual Studio 2010.

I found  that problem is in quadmath_snprintf, which converts __float128 to a string. 
Sometimes it returns correct result, sometimes - returned string is a junk. 
 
quadmath_snprintf relies heavily on stdio using FILE and others runtime features. 
Now runtimes are the same and I am out of ideas what can be wrong.

Same code compiled in MinGW runs nicely - no floating bugs.

Could it be something with how Visual Studio-compiled application loads DLL? Relocations or other? 
I've tried -Wl,--dynamicbase -Wl,--nxcompat, this also doesn't help.

I would appreciate any further ideas on how to build DLLs in MinGW so that they are compatible with usage in Visual Studio applications.
To sum up, I already have the same runtimes in MinGW & VS, enabled DEP/ASLR. 
But still IO functions in DLL give upredictable results, sometimes they work, sometimes they don't.

Pavel


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Dongsheng Song
On Wed, Oct 17, 2012 at 4:43 PM, Pavel Holoborodko <[hidden email]> wrote:

So you're wanting the dependent DLL to use MSVCR100?  Have you
considered using the static libraries instead?

Ah, yes, exactly, this solves the problem with different runtimes. Thank you!

However, unfortunately I still get the same unstable results using DLLs compiled by MinGW in Visual Studio 2010.

I found  that problem is in quadmath_snprintf, which converts __float128 to a string. 
Sometimes it returns correct result, sometimes - returned string is a junk. 
 
quadmath_snprintf relies heavily on stdio using FILE and others runtime features. 
Now runtimes are the same and I am out of ideas what can be wrong.

Same code compiled in MinGW runs nicely - no floating bugs.

Could it be something with how Visual Studio-compiled application loads DLL? Relocations or other? 
I've tried -Wl,--dynamicbase -Wl,--nxcompat, this also doesn't help.

I would appreciate any further ideas on how to build DLLs in MinGW so that they are compatible with usage in Visual Studio applications.
To sum up, I already have the same runtimes in MinGW & VS, enabled DEP/ASLR. 
But still IO functions in DLL give upredictable results, sometimes they work, sometimes they don't.

Pavel


Could you post a simple test source file to reproduce it ?



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Earnie Boyd
On Wed, Oct 17, 2012 at 8:51 PM, Dongsheng Song wrote:
>
> Could you post a simple test source file to reproduce it ?
>

And give the commands to compile and link it.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Orgulut
Could you post a simple test source file to reproduce it ?
And give the commands to compile and link it.

Thank you for your responses! 

I've prepared simple test case, please download zip file from here:

It contains two directories:
dll
test

"dll" has sources & scripts to build dll itself and test program (which uses the dll) by MinGW.
"test" has msvc project - test program which also uses same dll.

Additionally there are two files - configurations for gcc, used in compilation : specs, msvcr100. 
In my MinGW installation they live in mingw\lib\gcc\mingw32\4.7.0\ 
***

First, run make in "dll" directory - it will produce:
mingw-dll.dll
mingw-exe.exe

Then open MS solution in "test" and build the project. It will produce msvc-exe.exe and will copy it to "dll" automatically.

As a result, "dll" directory will have: 
mingw-dll.dll
mingw-exe.exe
msvc-exe.exe  

Two exe files are the test programs which use the same mingw-dll.dll
mingw-exe.exe always produce correct result (10 = 10).
msvc-exe.exe gives unpredictable output every time it runs (sometimes correct, sometimes not).

Everything is compiled with msvcr100 runtime. 

I would really appreciate any advice and help in this direction, since I am stuck at this problem.

Thank in advance,
Pavel.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Earnie Boyd
On Mon, Oct 22, 2012 at 4:34 AM, Pavel Holoborodko wrote:

>> Could you post a simple test source file to reproduce it ?
>> And give the commands to compile and link it.
>
>
> Thank you for your responses!
>
> I've prepared simple test case, please download zip file from here:
> http://holoborodko.com/pavel/downloads/mingw-test.zip
>
> It contains two directories:
> dll
> test
>
> "dll" has sources & scripts to build dll itself and test program (which uses
> the dll) by MinGW.
> "test" has msvc project - test program which also uses same dll.
>
> Additionally there are two files - configurations for gcc, used in
> compilation : specs, msvcr100.
> In my MinGW installation they live in mingw\lib\gcc\mingw32\4.7.0\
> ***
>
> First, run make in "dll" directory - it will produce:
> mingw-dll.dll
> mingw-exe.exe
>
> Then open MS solution in "test" and build the project. It will produce
> msvc-exe.exe and will copy it to "dll" automatically.
>

http://mingw.org/wiki/MixingCompilers

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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: MinGW/GCC based on MSVCR100 Runtime

Orgulut

http://mingw.org/wiki/MixingCompilers

I am well aware of the listed problems. 
However none of them are applied in this case (that is why I am seeking help on the list).

I do not use static libraries, I just try to use DLL compiled by MinGW in MSVC application.
All exported functions are in plain C, with POD as arguments, with the same calling sequence, no mangling, no cross-boundary memory allocations nor exceptions.
No struct alignment problem either. It is pretty bare metal C hard-cored DLL. 

Do you see any particular problem?




------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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