Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: speedreadersteve on February 01, 2023, 05:43:38 am

Title: Why do all my .cpp files take 5 seconds or longer to compile
Post by: speedreadersteve on February 01, 2023, 05:43:38 am
They used to take only 1 second or shorter, but ever since I compiled a 500+ line file - mostly of comments and ~200 lines code, a lot of statements in main() - it's taken a consistent 6 seconds.  This adds up when I'm debugging with print tests.

I'm using v20.03
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: stahta01 on February 01, 2023, 05:50:42 am
They used to take only 1 second or shorter, but ever since I compiled a 500 long file - mostly of comments and ~200 lines code, a lot of statements in main() - it's taken a consistent 6 seconds.  This adds up when I'm debugging with print tests.

Single source file project or more than one "C" or "C++" file?
If more than one, using an pre-compilied header might help.

If only one file, I would look to anti-virus or try defragging the harddrive (Note, that is if you are still using an normal hardrive; I am not sure if Solid State Harddrive is a good idea to defrag)

Tim S.
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: speedreadersteve on February 01, 2023, 05:58:35 am
I look at workspace and it contains nothing.  Every file is by itself. 

I'm new to programming, so I'm not too familiar with setting up projects or what they look like.  I always just start a new file rather than a new project, since I was more interested in learning the language than the platform.  The platform of codeblocks just looked simple enough for my needs.
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: BlueHazzard on February 01, 2023, 08:32:20 pm
Anti virus scanner?
Other processor load?
a build log? (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F )
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: speedreadersteve on February 01, 2023, 09:37:47 pm
"Anti virus scanner?
Other processor load?
a build log? (https://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F )"

Broken link on my end

Here's a build log

Set variable: PATH=C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\MinGW\bin;C:\Program Files\dotnet;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\FAHClient;A:\Apps\SocketeQ\windowsandroid_root\system\bin;A:\Apps\SocketeQ\windowsandroid_root\system\lib;C:\Users\User\AppData\Local\atom\bin;C:\Users\User\.dotnet\tools'

My two cents - It seems to be rebounding through a lot of C:drive paths, though I don't know why.  Shouldn't it just check a c++ compiler directory?
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: stahta01 on February 02, 2023, 04:26:42 am
https://wiki.codeblocks.org/index.php/Main_Page (https://wiki.codeblocks.org/index.php/Main_Page)

Code
https://wiki.codeblocks.org/index.php/Main_Page
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: BlueHazzard on February 02, 2023, 10:06:05 pm
Quote
Broken link on my end
What does this mean?

i copy the relevant part here
Code
Paste full build log here. (It is found in the 'Build log' tab). Please make always a 'rebuild' (Menu: Build->Rebuild) or a 'clean' and 'build' before you copy the full build log. 

Quote
Here's a build log

Set variable: PATH=C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\MinGW\bin;C:\Program Files\dotnet;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\FAHClient;A:\Apps\SocketeQ\windowsandroid_root\system\bin;A:\Apps\SocketeQ\windowsandroid_root\system\lib;C:\Users\User\AppData\Local\atom\bin;C:\Users\User\.dotnet\tools'
this is not the build log but your path...

also if you post the log, please use code tags (the # symbol in the forum editor)
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: speedreadersteve on February 04, 2023, 04:29:38 am
That's what I took from the "build log" tab at the bottom.  Is there another place?

#
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

Checking for existence: D:\Documents\C++ Scripts\Hacks\Garbage throwaway hacks\garbage.exe
Executing: '"C:\Program Files\CodeBlocks/cb_console_runner.exe" "D:\Documents\C++ Scripts\Hacks\Garbage throwaway hacks\garbage.exe"' (in 'D:\Documents\C++ Scripts\Hacks\Garbage throwaway hacks')
Set variable: PATH=C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\MinGW\bin;C:\Program Files\dotnet;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\FAHClient;A:\Apps\SocketeQ\windowsandroid_root\system\bin;A:\Apps\SocketeQ\windowsandroid_root\system\lib;C:\Users\User\AppData\Local\atom\bin;C:\Users\User\.dotnet\tools
Process terminated with status -1073741510 (0 minute(s), 9 second(s))
#
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: BlueHazzard on February 04, 2023, 10:20:36 am
You have to make a rebuild to see the build process. This is all described in the link above...
1) Load your project
2) Hit Build->Rebuild
3) Copy everything from the build log
4) paste it here and using the # symbol button in the forum editor toolbar, not the keyboard. Then there should appear code tags in the editor and between there paste the log
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: eckard_klotz on February 05, 2023, 10:27:21 am
Hello Speedreadersteve.

Initially you wrote:
Quote
... since I compiled a 500+ line file - mostly of comments and ~200 lines code, a lot of statements in main() - it's taken a consistent 6 seconds. ...

Please keep in mind that the compiler is not only processing the code lines written by you but all code lines in the header-files you have included. And this may result in your issue by just small changes in your self written code.

Before the compiler starts the translation of the file the preprocessor will extend your own code.

Especially today many modern libraries for example provided by the boost-project are based on meta-programming. But you may already have a similar effect if you just use a STL (Standard Template Library) provided by a standard C++ build suite.

Furthermore, if you use a meta-programming based library or a STL in a header, every cpp file that is including this header directly or indirectly will be affected by a combination of both effects.

I hope that this will give you an idea how you could blow up the build effort just by adding 1 or 2 lines of code.

You may reduce your resulting problems by a pre-compilation of your header files as suggested by the other discussion participants. Thus, please follow their advises.

However, you may already limit the initial root-cause by a refactoring of your software design.

Do you already use Doxygen (https://www.doxygen.nl/)? together with the tool Dot from Graphviz (http://www.graphviz.org/) ? This tool is able to provide you for every of your source-file an include graph that shows you not only the direct but the indirect included files. This graphs will help you to detect the most complex include dependencies.

Best regards,
                     Eckard Klotz.

PS.: Dear forum admin. I know, actually this is not a programming discussion. But I face very often similar issues in my own projects and had to learn over the time that the reason is not the tool (Code::Blocks, build-suite, ...) but in the most cases the software design. Thus I hope sharing my experiences will help to reduce the users frustration a little bit.
Title: Re: Why do all my .cpp files take 5 seconds or longer to compile
Post by: speedreadersteve on February 11, 2023, 02:51:46 am
It runs at 1-2 seconds now, after I rebooted my computer.  Maybe it was the CPU?