Code::Blocks
July 24, 2014, 07:43:12 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Don't forget to check the Nightly builds in the appropriate forum.
 
   Home   Help Search Login Register  :: WebsiteWiki  
Pages: [1] 2 3  All   Go Down
  Send this topic  |  Print  
Author Topic: GNU GCC Compiler is compiling REALLY slow.  (Read 15382 times)
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« on: October 02, 2005, 05:36:11 am »

I dont know why but the compiler im using is compiling really really slow, I had 4 lines of code and it took about 12 minutes and then starting making error reports about lines 100-2000. Is there somthing im doing wrong? The code i wrote was

#include "SDL.h"
int main ( int argc , char* argv [] )
{
  return ( 0 ) ;
}

And I'm pretty sure I have SDL set up correctly, but im not so sure about the compiler, is there some option I should check/uncheck?
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #1 on: October 02, 2005, 12:27:02 pm »

12 minutes is quite a mouthful... gcc is known to be somewhat slow, but this example should pretty much compile in 2-3 seconds normally, anyway. It does for me, anyway.

This gross timing looks like you are running out of physical memory (running Windows XP on a 128 MB machine or something?).
On my machine, gcc uses between 60 and 230 MB of physical memory, depending on the complexity of the input files (number of includes, etc).

Have a look at task manager while you compile, specifically enable the display of page faults. If page faults go up like crazy while compiling (and your hard disk light goes frenzy) then you know what is wrong.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #2 on: October 02, 2005, 09:17:36 pm »

When I do it with task manager up it makes CPU usage jump to 100%, but physical memory doesnt even flinch, I have over 750K of available physical mem, and when i go to the app's tab it says blocks is not responding.
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #3 on: October 02, 2005, 11:41:05 pm »

when i go to the app's tab it says blocks is not responding
Code::Blocks should be responding while compiling, as compiles run in a separate process and execution is non-blocking. The CPU time necessary to respond to a WM_ENABLE is not really a lot, so if Code::Blocks does not respond, something must prevent it from doing so.
One possibility would be a process with realtime priority which uses up all CPU cycles (it is rather safe to discard this hypothesis -- the compiler runs at "normal" priority, so the application would still process messages, even if 100% CPU is used, and what other processes would run only while compiling?).
The other possibility (the likely reason) is massive swapping.

I have over 750K of available physical mem
Did you really mean to say 750K? That would indeed mean that you have exceeded your RAM. 750k is practically zero.

Look at the number of page faults (enable the page faults column) to be sure.
cc1.exe has around 10.000-20.000 page faults on my system (depending on input file complexity) per run. Let's say that 20.000 is a "normal" number. If you run out of physical memory, you should see a lot more page faults (millions) in every process that takes up CPU, as it has to be swapped in each time its time slice is scheduled.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #4 on: October 03, 2005, 12:04:43 am »

750k as in 750,000. I have 1 gig of ram in my computer.
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #5 on: October 03, 2005, 12:56:17 am »

I have 1GB on this machine too, and I have on the order of 700MB free RAM while compiling, so I assume you really mean 750MB rather than 750kB .

That of course would rule out the theory of swapping (unless something is seriously amiss). Just to be sure anyway, did you ever look at the page faults?
Does the compiler (gcc.exe, or cc1.exe, or cc1-plus.exe, or some similar name) actually get CPU time at all (should be 99-100%)? And what is its memory consumption?
Have you tried disabling all non-vital services and closing all other applications including all those taskbar icons? The chances are small, but it has to be something...

I've been thinking about include files being read in recursively in an endless loop. That might, too, take an endless time and fail after a long time. However, I know for sure SDL does no such thing, it works fine for me using Code::Blocks and MinGW. Also, there is really not much you could possibly have done wrong, only need to copy all header files... Sounds unlikely that SDL is the problem.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #6 on: October 03, 2005, 01:06:31 am »

None of the things you listed (gcc.exe, or cc1.exe, or cc1-plus.exe) show up, its just codeblocks. Is that what is wrong? The way I compile? I just put the code into codeblocks and push the blue gear button at the top(when i keep my mouse over the button it is called compile, so i assume thats the right way to do it).
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #7 on: October 03, 2005, 02:33:11 am »

None of the things you listed (gcc.exe, or cc1.exe, or cc1-plus.exe) show up, its just codeblocks. Is that what is wrong?
Go to Compiler menu -> Compiler Options. Check your compiler executables are listed correctly under the "Programs" tab. Also check that you use the correct default compiler. If not, try auto-detect, and if that fails for some reason, enter the paths by hand.
While compiling, the mentioned programs should show in task manager (only for a second or two, usually).

I just put the code into codeblocks and push the blue gear button at the top
Umm... this sounds like you do not have a project at all? That is surprising, should not be possible at all... do you use an old version of Code::Blocks? RC1-1 disables the blue gear when there is no active project. Or, do you maybe have another project as the active project and compile that one by accident?

EDIT:
To clarify the last point... in the project manager to the left, whatever project prints in bold is what gets compiled when you hit the blue gear -- not the file that happens to be open in the editor.
RC1-1 does have a function called "Compile single file" too, accessible from the compiler menu, earlier versions don't.
« Last Edit: October 03, 2005, 02:38:09 am by thomas » Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #8 on: October 03, 2005, 03:01:32 am »

Yea i have a project, i did new project, sdl app, then copy the code into it, then use the blue gear. and in the programs tab, im not really sure how to configure it. but this is how it is after auto detect.

C compiler: mingw32-gcc.exe
C++ compiler: mingw32-g++.exe
linker for dynamic libs: mingw32-g++.exe
linker of static libs: ar.exe
debugger: gdb.exe
resource compiler: windres.exe
make program: mingw32-make.exe

Are they all on the right files?
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #9 on: October 03, 2005, 10:28:36 am »

in the programs tab, im not really sure how to configure it. but this is how it is after auto detect.
[...]
Are they all on the right files?
Yes, those are the right file names, and since you do not get an "execute failed" error, the path is ok as well.
It surprises me that the compiler does not show in task manager, it really should. Which process takes up all the CPU time when you have task manager open?

Did you ever try to compile something else, say a simple empty standard-C main() function with no includes?
Just to see if anything compiles at all. If that works, then it is probably not a compiler problem.

On a different subject, your code sample should have #include <SDL.h> instead of #include "SDL.h". Of course that is merely cosmetic, and not likely the cause of your problem. Still, it is "more correct", since SDL.h is in the system include folder rather than the project folder.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #10 on: October 04, 2005, 12:30:50 am »

codeblocks.exe takes up all the cpu time when compiling.

With the code main(); i got an error of: main.cpp   line  1  message, error: expected constructor, destructor, or type conversion before ';' token.

Took about 14 minutes to finish compiling and give me the error.
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #11 on: October 04, 2005, 04:08:47 pm »

So it is either a bad compiler setup, or more likely something's wrong with your Code::Blocks install. Obviously, you don't need to think about SDL before you can compile int main(){return 0;}.
Unluckily, this kind of problem can be quite hard to solve. You could use an odd version of either the IDE or the compiler (maybe a custom build, too), or might miss some files, have dll conflicts, or whatever... some people have reported problems with non-ASCII characters in a pathname - the possibilities are manifold.

When first using Code::Blocks, I had version conflicts, too (although it was clearly my own fault). What I learned from this was to keep things as simple as possible. The simpler, the better.

Here is a foolproof install that does work reliably:

  • Deinstall Code::Blocks and remove anything that you installed by hand (like 5 different compiler versions)
  • Download the current release candidate of Code::Blocks without compiler from here:
    http://prdownloads.sourceforge.net/codeblocks/codeblocks-1.0-rc1-1.exe?download
  • Install Code::Blocks into C:\codeblocks -- do not use a fancy path with spaces or special characters
  • Make a folder C:\mingw - again, no fancy names, keep things as simple as possible
  • Finding the right files to download is a bit tricky if you have never installed MinGW manually. I made a list in the WiKi that contains links to all you need: http://wiki.codeblocks.org/index.php/MinGW_installation
    Decide whether you want 3.4.2 or 3.4.4 (not both!), and download everything under "Base system with C++"  (plus anything you want from "optional").
  • Put all the downloaded files into the folder C:\mingw that you created earlier.
  • Unpack them all (I assume you have some kind of file archiving utility like 7z, WinZip, WinRar, PowerArc, or else). The usually available "decompress here" item from the Explorer context menu does the right job.
  • If you have cygwin on your PC, make sure cygwin's binary and library dirs are not in your PATH. If you really want to include them, make sure they come last. Otherwise, you can get the strangest and nastiest errors, not only with Code::Blocks, but also with other programs (for example, gaim is known to crash due to this, and some standard tools coming with cygwin are... well, let's not pronounce it).
  • If you want to eventually use the commandline tools from a DOS window, add C:\mingw\bin to your path (not necessary if you only use Code::Blocks).
  • Start Code::Blocks, it should prompt you for the compiler you installed. If it does not, go to compiler options, and use auto-detect like you already did once, or enter C:\mingw manually, whichever you like.
  • Make a console project from a template, save it to C:\test (again, no fancy names) and compile it.
    This must not take longer than maybe 1-2 seconds, and it must not fail.
  • Now, after this worked, you can get more courageous and try something else, like SDL and fancy pathnames, adding third-party plugins, etc.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #12 on: October 04, 2005, 09:40:09 pm »

Ok I downloaded all the 3.4.4 base files and the debugger, but is there anything else i should do? Any install to run besides the debugger? When I go into code::blocks its not finding any of the files and I dont know what to put there, but I looked at my previous post where i had.

C compiler: mingw32-gcc.exe
C++ compiler: mingw32-g++.exe
linker for dynamic libs: mingw32-g++.exe
linker of static libs: ar.exe
debugger: gdb.exe
resource compiler: windres.exe
make program: mingw32-make.exe

but the apps in the mingw folder are: add2line, c++, cpp, dos2unix, drmingw, mingw32-make, pexports, redir, reimp, res2coff, test, testcpp, unix2dos.
So trying to find the matching files wont work. Am I missing a few files?
Logged
thomas
Administrator
Lives here!
*****
Offline Offline

Posts: 3938



« Reply #13 on: October 04, 2005, 10:52:05 pm »

Right above all these is "installation path:". Enter C:\mingw there.
Logged

"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."
Alos
Advanced newcomer
*
Offline Offline

Posts: 11


« Reply #14 on: October 05, 2005, 12:56:00 am »

Ok its in there. what next? Trying to compile with just that gets me: cant find executable in your search path for GNU GCC Compiler.
Logged
Pages: [1] 2 3  All   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!