Thread: g++ is very slow when compared to cl

  1. #1
    Banned
    Join Date
    Nov 2007
    Posts
    678

    g++ is very slow when compared to cl

    when i compile my .cpp files i feel that g++ is very slow.
    i thought it was natural since C++ is very complex to compile.
    but when i run cl on same files it compiles much faster.

    are there any options to make g++ run faster. or may be my g++ version is old. although i am using latest MinGW package.

    cl is the name of Microsoft Compiler. I have MSVC .Net 2003 but I use it from command line only!

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Moved to Tech board.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    The Microsoft compiler is indeed considerably faster than GCC. Since its source is not available, we don't know why that is.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by CornedBee View Post
    The Microsoft compiler is indeed considerably faster than GCC. Since its source is not available, we don't know why that is.
    The usual reason for g++ slowness is the speed of parsing the STL code, which is included pretty much everywhere. I'd guess that Visual Studio has precompiled headers for most things, which makes a huge difference. g++ supports them now, sort of...

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I believe even VS doesn't use precompiled headers for the STL unless you tell it to. Besides, VC++ is faster at compiling complicated Boost stuff, too, and that far exceeds the STL in size.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    The only thing that interests me is which one of them optimizes better.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    In general, that prize goes to MS's compiler as well. Though the 4.x series of GCC is considerably better than the 3.x series and is very close, sometimes better.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by CornedBee View Post
    In general, that prize goes to MS's compiler as well. Though the 4.x series of GCC is considerably better than the 3.x series and is very close, sometimes better.
    Well, I work on a reverse engineering project of an application compiled with GCC and one other guy I know works on the next version of it, which is compiled with MSVC. He said that version had alot worse assembly than the GCC one had... also, there weren't too many new features but the size of the executable grew about 8 times.

    The games are GTA:Vice City and GTA:San Andreas and the reversing projects are VC:MP and SA:MP.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    *shrug*
    That's the thing about generalizations.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Banned
    Join Date
    Nov 2007
    Posts
    678
    CornedBee: I did not understand that.

    My g++ was so slow that it took the whole night to compile Qt.
    I left the PC on for the night. And by the morning it was almost done

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Hmm... that must be some other problem then. I compiled Qt before on my aged laptop, and while trying to decide between it and wxWidgets, and it took me... 30 minutes? Yes, g++.

    I can tell you however mingw's g++ is indeed slower and produces more bloated code than VC++. This became very obvious to me when I started using the wxWidgets framework. However under Linux, the same library compiles considerably faster and with less code bloat. So, it must probably a port thing.

    Regardless I used to use g++ extensively on windows. It's a great compiler, has a good debugger and goes along just fine with all the IDEs we like. I used VC++ specifically only for my wxWidgets project. But now I migrated to Linux, and am considering moving the wxWidgets project too, since my preliminary observations revealed g++ there to be as good as VC++ is on windows.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Mario F. View Post
    I can tell you however mingw's g++ is indeed slower and produces more bloated code than VC++. This became very obvious to me when I started using the wxWidgets framework. However under Linux, the same library compiles considerably faster and with less code bloat. So, it must probably a port thing.
    How can you tell that? Have you examined some disassembly?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  13. #13
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Mario: I have also compiled some plain C++ programs with g++. Even the simplest "Hello, World" type takes so much time, that i can more than just notice the time taken.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Mario: I have also compiled some plain C++ programs with g++. Even the simplest "Hello, World" type takes so much time, that i can more than just notice the time taken.
    That is definitely unusual. What are your system specs, and what version of g++ are you running?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    But Visual Studio 2003 is quite outdated. The least you should be using is 2005, since it's considerably more standards compliant. Best use 2008, though. It's even more standards compliant.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CL and C++
    By siavoshkc in forum C++ Programming
    Replies: 1
    Last Post: 09-24-2006, 03:01 PM
  2. Program is slow. Help
    By jjj93421 in forum C++ Programming
    Replies: 14
    Last Post: 08-08-2004, 07:39 AM
  3. slow game
    By lambs4 in forum Game Programming
    Replies: 2
    Last Post: 08-21-2003, 02:08 PM
  4. Solutions for slow performance?
    By Hunter2 in forum Game Programming
    Replies: 52
    Last Post: 08-24-2002, 10:04 AM
  5. slow load of Cprog.com
    By Generator in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-13-2001, 06:31 AM