Author Topic: Static vs Dynamic runtimes with GCC & VCTK  (Read 15246 times)

chep

  • Guest
Static vs Dynamic runtimes with GCC & VCTK
« on: June 10, 2005, 10:26:51 am »
Hi,

I don't really know much of GCC and VCTK (I'm used to work with C++Builder) so I was wondering...

I noticed that with default options, GCC is linking against the dynamic runtime (msvcrt.dll) whereas VCTK uses the static runtime.

How can I use the static runtime with GCC, or the dynamic runtime with VCTK ?
And are there, like for BCC, both Single Threaded and Multi Threaded versions of the runtime ?

I didn't find relevant information about this. :(

Thanks

montchai

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #1 on: August 06, 2005, 05:41:34 pm »
Same as me guy, I had some problem with building Multi-Threading DLL too. And I don't know how to build it. And in the main problem, "Why does no one help us to solves our problem?"

Offline troels

  • Multiple posting newcomer
  • *
  • Posts: 71
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #2 on: August 06, 2005, 11:26:28 pm »
How can I use the static runtime with GCC, or the dynamic runtime with VCTK ?

With VCTK, dynamic is /MD, static is /MT.
Using msvcrt.dll is free, also for users of gcc, but the code inside the dll is not free, it's Microsofts property. So the gcc people cannot provide the code, in a .lib/.a, it's not theirs to give out. (I didn't see this in print anywhere, it's only - qualified? - speculation)

Regards,
Troels
« Last Edit: August 06, 2005, 11:28:49 pm by troels »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #3 on: August 07, 2005, 03:39:53 am »
The reason why nobody seems to help you is that nobody seems to use MSVC Toolkit :(

At least I don't use MSVC, Yiannis has some knowlegde about it, but he's on vacations for 3-weeks. Anyway, I think  that in the project options you need to add the libraries for multi-threaded code by yourself, until we have more research done on MSVC projects importing.

There was a similar Issue on BCC compilers, but I'm afraid we're not able to support multi-threaded libs "out of the box" before 1.0 comes out.

Offline kagerato

  • Multiple posting newcomer
  • *
  • Posts: 56
    • kagerato.net
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #4 on: August 07, 2005, 04:49:48 am »
What precisely is the benefit of using Microsoft's compiler?

Are the binaries even gdb-compatible?  (In other words, can gdb read the symbols generated by MSVC?  I'm doubtful.)

People say that MinGW is slow, but there have been virtually no benchmarks to back up this assertion.  If valid statistics do exist, why are they not widely published?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #5 on: August 07, 2005, 04:52:12 am »
GCC _IS_ slow in compilation times. Regarding runtimes, programs are as fast as others.

See, compiling Code::Blocks using Digital Mars takes around 2 or 3 minutes. Under GCC it takes about 10 minutes. (The benchmarks were somewhere around the forums).

Offline kagerato

  • Multiple posting newcomer
  • *
  • Posts: 56
    • kagerato.net
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #6 on: August 07, 2005, 06:08:16 pm »
GCC _IS_ slow in compilation times. Regarding runtimes, programs are as fast as others.

See, compiling Code::Blocks using Digital Mars takes around 2 or 3 minutes. Under GCC it takes about 10 minutes. (The benchmarks were somewhere around the forums).

 :shock: You're right.  I downloaded Open Watcom yesterday and built wxWidgets using it (instead of the usual g++).  The library built in five (!) minutes, rather than the fifteen it takes MinGW to work through it.

That factor of three becomes more significant when you know the hardware I'm building with: a pentium 4 (dual-core) 3.2 GHz CPU and 2 gbyte RAM.  If the difference is so great on this machine, it will only be larger on less powerful ones.

Such a time differential could make a difference; I see now why some have little praise for MinGW...

takeshimiya

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #7 on: August 07, 2005, 06:24:47 pm »
If you are amazed with Open Watcom, try with Digital Mars.
I've not tried myself to compile wx but the wxHatch autor made some benchmarks here.

Time to compile in debug build wxWidgets 2.5.3:
GCC 3.2:  47:14 minutes
Digital Mars: 2:34 minutes

To say GCC is slow in compiling time is perhaps a little gentle :o

Also, wxWidgets 2.5.3 total library sizes in MBytes in debug build:
GCC 3.2: 356 MB
Digital Mars: 31 MB

So, taking in account the benchmarks, I can conclude that Digital Mars is a very good option while developing, and GCC is a good option for distributing and releasing.
« Last Edit: August 07, 2005, 06:27:29 pm by takeshimiya »

Offline kagerato

  • Multiple posting newcomer
  • *
  • Posts: 56
    • kagerato.net
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #8 on: August 07, 2005, 08:30:27 pm »
If you are amazed with Open Watcom, try with Digital Mars.

Digital Mars is not open source.  Nor does it provide a debugger.

Quote
So, taking in account the benchmarks, I can conclude that Digital Mars is a very good option while developing, and GCC is a good option for distributing and releasing.

With debug binaries that small, I fail to see what kind of information one expects to derive from them.  Concerning just symbols alone, what kind of verbosity are we looking at here?  Probably not much.  Though this already assumes that one can find a third-party debugger which is compatible and useful in the first place.

Optimization is likely pretty poor (if it exists at all) with a compilation time that short.

I don't expect a large library to rebuild instantaneously.  Five minutes seems quite sufficient considering the code base involved.

takeshimiya

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #9 on: August 07, 2005, 09:21:35 pm »
Well, of course if you compare it to Open Watcom the difference isn't so huge, but anyways, as you said, 

It's 5 minutes in OpenWatcom BUT if you have: "A pentium 4 (dual-core) 3.2 GHz CPU and 2 gbyte RAM".
Most of us don't have that processing power :(

BTW, comparing your benchmarks and the benchmarks made by wxHatch, seems to have almost the same ratio:

Time to compile in debug build wxWidgets 2.5.3:
GCC 3.2:  47:14 minutes
Open Watcom 1.3: 16:04 minutes
Digital Mars: 2:34 minutes

So,  the ratio for GCC vs. Open Watcom is 3:1
and the ratio for GCC vs. Digital Mars is 20:1 :shock:

It wouldn't be illogical then, to think that you can compile with your HIGH spec pc, the complete wxWidgets library using DMars in 45 seconds.


Better not to talk about the optimizations of Open Watcom. GCC is very good though (lower is better, in milliseconds):
Open Watcom 1.1 DEBUG: 11922 ms
Open Watcom 1.1 RELEASE: 6578 ms
GCC 3.2 RELEASE: 2031 ms
DMars DEBUG: 3812 ms

You can see DMars in DEBUG mode outperforms Open Watcom even in RELEASE mode.

About the debugger, DMars works with Symantec, Zortech, Rational Systems, Multiscope, and Microsoft debuggers (dunno about GDB).
Anyways there will be a point (hopefully) when you probably rarely need a debugger (I know that there are people that doesn't debuggers anymore)

The more compilers (that support the standards) the better :)
« Last Edit: August 07, 2005, 09:47:33 pm by takeshimiya »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #10 on: August 07, 2005, 09:25:12 pm »
Optimization is likely pretty poor (if it exists at all) with a compilation time that short
According to various benchmarks I found on the net, that is (surprisingly) not true. gcc uniformly performs singnificantly (around 20-30%) worse than MSVC and DM which are both more or less equal.

But then, "impartial benchmark" is maybe the strongest oxymoron in existence. Personally, I doubt that such gross numbers reflect anything that is even remotely true in a "real" application. More likely, either the commercial compilers are actually optimized to 'cheat' in known synthetic benchmarks, or there is a systematic error in the assay (comparing debug to release maybe?).
One other thing to note is that those infavourable benchmarks use really old versions of gcc, so it is even more uncertain in how far they are accurate today.

My personal experience building wxWidgets is:
gcc 3.4.422:11 minutes
Digital Mars1 second (bailing out after 5 or 6 errors)
To me, that is gcc 100 points, DM zero.

Maybe gcc is slow, I care not. It never failed me, and it is a mighty fine compiler.
Who needs to rebuild of wxWidgets 5 times per day, anyway. :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #11 on: August 07, 2005, 09:39:38 pm »
Not exactly wxWidgets (DMars isn't optimized to only compile faster wxWidgets :lol:)
But I found myself compiling and rebuilding Code::Blocks more than 5 times per day (I guess I'm not the only one).

Compiling the entire Code::Blocks tooks me more than 10 minutes.
If DMars were supported (note that the only currently compiler tested for C::B is GCC) for compiling Code::Blocks itself, I would be compiling it in 30 seconds.
That for sure means a lot to me.

But Yiannis told that one of these days other compilers would be supported also. :)

Regarding speed of execution (optimization), probably the best compiler is the Intel Compiler, at least in my experience.
« Last Edit: August 07, 2005, 09:44:13 pm by takeshimiya »

Offline kagerato

  • Multiple posting newcomer
  • *
  • Posts: 56
    • kagerato.net
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #12 on: August 08, 2005, 01:57:00 am »
It's 5 minutes in OpenWatcom BUT if you have: "A pentium 4 (dual-core) 3.2 GHz CPU and 2 gbyte RAM".
Most of us don't have that processing power :(

Unfortunately.

Quote
BTW, comparing your benchmarks and the benchmarks made by wxHatch, seems to have almost the same ratio:

(...)

It wouldn't be illogical then, to think that you can compile with your HIGH spec pc, the complete wxWidgets library using DMars in 45 seconds.

The ratios are approximately the same indeed.  DMC takes a bit longer than 45 seconds; my timer says 58 seconds.

Quote
Better not to talk about the optimizations of Open Watcom. GCC is very good though (lower is better, in milliseconds):
Open Watcom 1.1 DEBUG: 11922 ms
Open Watcom 1.1 RELEASE: 6578 ms
GCC 3.2 RELEASE: 2031 ms
DMars DEBUG: 3812 ms

You can see DMars in DEBUG mode outperforms Open Watcom even in RELEASE mode.

If these figures are accurate, then Digital Mars is quite the piece of work.

Open Watcom 1.3 is the newest release.  However, I don't expect that any of its versions can really compare to the extensive optimizations applied by GCC.

Quote
About the debugger, DMars works with Symantec, Zortech, Rational Systems, Multiscope, and Microsoft debuggers (dunno about GDB).
Anyways there will be a point (hopefully) when you probably rarely need a debugger (I know that there are people that doesn't debuggers anymore)

The docs say that it supposedly supports this ".map" format, but I have no idea how to use that.  None of those debuggers seem to be integrated into anything I can download for free, so even if one was to obtain the debugger he would still need some commercial IDE to make the whole process efficient.

GDB has the kind of high-level integration with tools that I enjoy.  Microsoft's development environments work similarly (or better) with their debugger(s), but it's all commercially-oriented.  Besides, most of their tools are .NET-centric now.

Quote
The more compilers (that support the standards) the better :)

Agreed.

Quote from: thomas
Who needs to rebuild of wxWidgets 5 times per day, anyway.

Normally, I don't even need to build it once a day.  However, I happen to be messing around with the features in setup.h (and of course you must rebuild to see the effects).

grv575

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #13 on: August 08, 2005, 04:13:16 am »
The intel compiler definately does the best optimization, but I was under the impression that even msvc does more optimization than gcc.  IOW, the MS and intel compilers can afford to be more platform specific.

takeshimiya

  • Guest
Re: Static vs Dynamic runtimes with GCC & VCTK
« Reply #14 on: August 08, 2005, 04:33:03 am »
Yes, the MSVC compiler does more optimization than GCC, that's why almost all fast firefox unofficial builds are being made with MSVC 2003 and 2005 instead of the default GCC. No one got working mozilla in the Intel compiler yet.

It really depends on what are your needings, however I think that anyone must use more than one compiler, to make sure your code is cross-compiler.

When you want:
-Very fast compilation times, Digital Mars is the best for the task (Borland 5.5 sometimes also).
-Very optimized programs, the Intel Compiler is the best (followed by the latests releases of MSVC)
-Very small executable size, the MSVC is one of the best (Borland and Digital Mars sometimes also)
-Normally optimized programs, very big executable size, the worst compilation times, but the most supported compiler that runs on almost all architectures, the king is GCC (the slow compilation times are expected to change when GCC4 matures).

Currently the de-facto standard in the opensource is GCC, so always the code must compile in GCC.

A note about the Digital Mars debugger, you can use free debuggers like ones from Microsoft: (Codeview, symdeb, windbg, and VC++ debugger) ie. Instructions for windbg.
« Last Edit: August 10, 2005, 11:32:29 pm by takeshimiya »