Official support for precompiled headers
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
Hi Marfi,
CodeLite now supports pre-compiled headers (trunk version).
To enable it, just set the header name under project settings -> Compiler -> Precompiled header
Let me know if there is anything else that I missed.
Eran
CodeLite now supports pre-compiled headers (trunk version).
To enable it, just set the header name under project settings -> Compiler -> Precompiled header
Let me know if there is anything else that I missed.
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Curious
- Posts: 9
- Joined: Wed Jul 22, 2009 11:39 am
- Contact:
Re: Official support for precompiled headers
I am using codelite 2.0 under windows. It seems that pre-compile header setting just do nothing to me...Well, I enable the -H,and watch build output. Codelite always compile the .h file(which I wish to be pre-compiled) first, then compile the rest one.
Indeed , g++ will find .gch when compiling .cpp files. But, codelite always compile the pre-compile header that bothering me. It is very ,very slow... I am the guy who often do small modification to .cpp then compile whole project....I thought pre-compiled header shoulde be compiled only once after modification and codelite should never compile it again after that...
Indeed , g++ will find .gch when compiling .cpp files. But, codelite always compile the pre-compile header that bothering me. It is very ,very slow... I am the guy who often do small modification to .cpp then compile whole project....I thought pre-compiled header shoulde be compiled only once after modification and codelite should never compile it again after that...
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
What is this: -H?karnon wrote:I enable the -H
To enable pre-compiled header feature in codelite, just place in the 'project settings -> compiler' tab the path to the header file which you want to be the 'pre-compiled' header.
Another suggestion (more like speculation):
Maybe one of the included files as a timestamp in the future? which will always cause a rebuild AFAIK
No need to mention that it works for me, right ?
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Curious
- Posts: 9
- Joined: Wed Jul 22, 2009 11:39 am
- Contact:
Re: Official support for precompiled headers
-H: enable this option so that gcc will print out header file that it's compiling.
So, if you enable -H, you will find that codelite compile pre-compile header every time. For example, I am using boost/xpressive library. I have set pre-compile header following your instruction, and I got *.gch file also. The problem is, codelite produce *.gch every time I compile my project, no matter *.gch exits or not, which is time consuming.
If I disable -H option, well, nothing will print out, but compiling time is still long, because codelite is still compiling pre-compile header to general *.gch quietly.
---------sample code----------
-----main.cpp--------
#include "stdafx.h"
using namespace std;
int main(int argc, char **argv)
{
int i;
i = 2;
i++;
cout<<"hji"<<endl;
return 1;
}
-----------------stdafx.h-------------------
#include <string>
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
--------------------------end------------
my boost library is install under d:\boost_1.41. And compiling time is about 20 secs in codelite(with pre-compile header), while it is only a second if I invoke '" g++ main.cpp " after " g++ stdafx.h ".
"g++ main.cpp -H" will output:
! stdafx.h.gch
main.cpp
main.cpp
It means that stdafx.h.gch is working. Otherwise, it will output lots of things.....
So, if you enable -H, you will find that codelite compile pre-compile header every time. For example, I am using boost/xpressive library. I have set pre-compile header following your instruction, and I got *.gch file also. The problem is, codelite produce *.gch every time I compile my project, no matter *.gch exits or not, which is time consuming.
If I disable -H option, well, nothing will print out, but compiling time is still long, because codelite is still compiling pre-compile header to general *.gch quietly.
---------sample code----------
-----main.cpp--------
#include "stdafx.h"
using namespace std;
int main(int argc, char **argv)
{
int i;
i = 2;
i++;
cout<<"hji"<<endl;
return 1;
}
-----------------stdafx.h-------------------
#include <string>
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
--------------------------end------------
my boost library is install under d:\boost_1.41. And compiling time is about 20 secs in codelite(with pre-compile header), while it is only a second if I invoke '" g++ main.cpp " after " g++ stdafx.h ".
"g++ main.cpp -H" will output:
! stdafx.h.gch
main.cpp
main.cpp
It means that stdafx.h.gch is working. Otherwise, it will output lots of things.....
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
From the example you pasted here (works for me..)
Try to remove the boost files from it, and see if it makes a different, since 'make' decides which file to build based on timestamp
Eran
Try to remove the boost files from it, and see if it makes a different, since 'make' decides which file to build based on timestamp
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Curious
- Posts: 9
- Joined: Wed Jul 22, 2009 11:39 am
- Contact:
Re: Official support for precompiled headers
so , you appended '-H' option ?
I removed Boost library, and pressed F7, and got these:
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "codeliteworkspace_wsp.mk""
----------Building project:[ testxpressive - Debug ]----------
. F:/tmp/codeliteworkspace/stdafx.h -----------Please NOTE THISE LINE
.. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/string
... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/c++config.h
.... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/os_defines.h
.... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/cpu_defines.h
...........lots of things........ommitted....
! F:/tmp/codeliteworkspace/stdafx.h.gch
F:/tmp/codeliteworkspace/main.cpp
F:/tmp/codeliteworkspace/main.cpp
g++ -o ./Debug/testxpressive ./Debug/main.o "-L."
----------Build Ended----------
0 errors, 0 warnings
The line ". F:/tmp/codeliteworkspace/stdafx.h" indicates that codelite invoked g++ to compile stdafx.h ( I guess) .
Did you get the same output? Or it just appealed only on my platform ?
Thanks:)
I removed Boost library, and pressed F7, and got these:
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "codeliteworkspace_wsp.mk""
----------Building project:[ testxpressive - Debug ]----------
. F:/tmp/codeliteworkspace/stdafx.h -----------Please NOTE THISE LINE
.. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/string
... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/c++config.h
.... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/os_defines.h
.... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32/bits/cpu_defines.h
...........lots of things........ommitted....
! F:/tmp/codeliteworkspace/stdafx.h.gch
F:/tmp/codeliteworkspace/main.cpp
F:/tmp/codeliteworkspace/main.cpp
g++ -o ./Debug/testxpressive ./Debug/main.o "-L."
----------Build Ended----------
0 errors, 0 warnings
The line ". F:/tmp/codeliteworkspace/stdafx.h" indicates that codelite invoked g++ to compile stdafx.h ( I guess) .
Did you get the same output? Or it just appealed only on my platform ?
Thanks:)
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
Hi,
This is the output that I get for the first time I compile:
On the next build, I get this:
So, as you can see I dont need the -H option
Note that I am using different version of codelite (trunk version) - but i tshould not matter.
Also, as you can see 'make' says 'stdafx.h.gch' is up-to-date - so its compilation is skipped (as you would expect)
Can you do this test:
Remove stdafx.h from being a pre-compiled header, and build your project again, does make re-compiles main.cpp? or is it skipping to the link directly?
(try to build your project several times, to see if main.cpp is always being compiled)
Eran
This is the output that I get for the first time I compile:
Code: Select all
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "TestPreCompiled_wsp.mk""
----------Building project:[ TestPreCompiled - Debug ]----------
mingw32-make.exe[1]: Entering directory `C:/TestArea/TestPreCompiled'
g++ -c stdafx.h -g "-I." "-I."
mingw32-make.exe[1]: Leaving directory `C:/TestArea/TestPreCompiled'
mingw32-make.exe[1]: Entering directory `C:/TestArea/TestPreCompiled'
g++ -c "C:/TestArea/TestPreCompiled/main.cpp" -g -o ./Debug/main.o "-I." "-I."
g++ -o ./Debug/TestPreCompiled ./Debug/main.o "-L."
mingw32-make.exe[1]: Leaving directory `C:/TestArea/TestPreCompiled'
----------Build Ended----------
0 errors, 0 warnings
Code: Select all
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "TestPreCompiled_wsp.mk""
----------Building project:[ TestPreCompiled - Debug ]----------
mingw32-make.exe[1]: Entering directory `C:/TestArea/TestPreCompiled'
mingw32-make.exe[1]: `stdafx.h.gch' is up to date.
mingw32-make.exe[1]: Leaving directory `C:/TestArea/TestPreCompiled'
mingw32-make.exe[1]: Entering directory `C:/TestArea/TestPreCompiled'
g++ -o ./Debug/TestPreCompiled ./Debug/main.o "-L."
mingw32-make.exe[1]: Leaving directory `C:/TestArea/TestPreCompiled'
----------Build Ended----------
0 errors, 0 warnings
Note that I am using different version of codelite (trunk version) - but i tshould not matter.
Also, as you can see 'make' says 'stdafx.h.gch' is up-to-date - so its compilation is skipped (as you would expect)
Can you do this test:
Remove stdafx.h from being a pre-compiled header, and build your project again, does make re-compiles main.cpp? or is it skipping to the link directly?
(try to build your project several times, to see if main.cpp is always being compiled)
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Curious
- Posts: 9
- Joined: Wed Jul 22, 2009 11:39 am
- Contact:
Re: Official support for precompiled headers
Hi,
My version is 3365, downloaded from main page.
Well, with out "-H", I got almost the same as yours:
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "codeliteworkspace_wsp.mk""
----------Building project:[ testxpressive - Debug ]----------
mingw32-make.exe[1]: `F:\tmp\codeliteworkspace\stdafx.h.gch' is up to date.
g++ -o ./Debug/testxpressive ./Debug/main.o "-L."
----------Build Ended----------
0 errors, 0 warnings
But, in the test, "mingw32-make.exe[1]: `F:\tmp\codeliteworkspace\stdafx.h.gch' is up to date." doesn't means compiling stdafx.h is skipped( This is the KEY POINT! ). I added "-H" so that I can watch whether stdafx.h is compiled or not. If it's not, than gcc will print nothing, other wise gcc will print the compiling header file.
I suggest we should include a big,big header file for testing, somethin like boost/xpressive. If stdafx.h is compiled , it will take a long time. If only main.cpp is compiled, it only need a second. In your test mentioned before, you cannot discern the differnece of compiling time ( Of cause it seems "very thing is fine" if just looking at the codelite's report).
As your suggestion , if I remove stdafx.h from being pre-compile header, then it is normal. The header file compiling process is never skipped, and there is no *.gch file generated.
To make it short, I guess, when pre-compile header is added, codelite do the following things:
1, saying "stdafx.h.gch' is up to date" if there is a newest *.gch file, or, compile it to get *.gch
2, EVEN there is *.gch, codelite still compile stdafx.h without reporting this action. It can be demonstrated by adding "-H" to gcc compile-option.------ This step is not EXCEPTED...
3,compile main.cpp as mormal. If there is *.gch, then use it.
My version is 3365, downloaded from main page.
Well, with out "-H", I got almost the same as yours:
----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -j 2 -f "codeliteworkspace_wsp.mk""
----------Building project:[ testxpressive - Debug ]----------
mingw32-make.exe[1]: `F:\tmp\codeliteworkspace\stdafx.h.gch' is up to date.
g++ -o ./Debug/testxpressive ./Debug/main.o "-L."
----------Build Ended----------
0 errors, 0 warnings
But, in the test, "mingw32-make.exe[1]: `F:\tmp\codeliteworkspace\stdafx.h.gch' is up to date." doesn't means compiling stdafx.h is skipped( This is the KEY POINT! ). I added "-H" so that I can watch whether stdafx.h is compiled or not. If it's not, than gcc will print nothing, other wise gcc will print the compiling header file.
I suggest we should include a big,big header file for testing, somethin like boost/xpressive. If stdafx.h is compiled , it will take a long time. If only main.cpp is compiled, it only need a second. In your test mentioned before, you cannot discern the differnece of compiling time ( Of cause it seems "very thing is fine" if just looking at the codelite's report).
As your suggestion , if I remove stdafx.h from being pre-compile header, then it is normal. The header file compiling process is never skipped, and there is no *.gch file generated.
To make it short, I guess, when pre-compile header is added, codelite do the following things:
1, saying "stdafx.h.gch' is up to date" if there is a newest *.gch file, or, compile it to get *.gch
2, EVEN there is *.gch, codelite still compile stdafx.h without reporting this action. It can be demonstrated by adding "-H" to gcc compile-option.------ This step is not EXCEPTED...
3,compile main.cpp as mormal. If there is *.gch, then use it.
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
Have you tried placing block guard in your header file?karnon wrote:But, in the test, "mingw32-make.exe[1]: `F:\tmp\codeliteworkspace\stdafx.h.gch' is up to date." doesn't means compiling stdafx.h is skipped( This is the KEY POINT! ). I added "-H" so that I can watch whether stdafx.h is compiled or not. If it's not, than gcc will print nothing, other wise gcc will print the compiling header file.
Code: Select all
#ifndef STDAFX_H
#define STDAFX_H
..
#endif
Make sure you have read the HOW TO POST thread
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
You are wrong here.karnon wrote:The line ". F:/tmp/codeliteworkspace/stdafx.h" indicates that codelite invoked g++ to compile stdafx.h ( I guess) .
the number of dots ('.') means the depth level of the file found by the pre-processor of g++
if the file was compiled, you would see something like this:
Code: Select all
g++ -c precmp.h -g -H "-I." "-I."
x precmp.h.gch
. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/../../../../include/stdio.h
.. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/../../../../include/_mingw.h
.. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/stddef.h
... MORE LINES HERE
Code: Select all
. C:/TestArea/TestPreCompiledHeader/precmp.h
.. c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/../../../../include/stdio.h
... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/../../../../include/_mingw.h
... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/stddef.h
... c:\mingw-4.4.0\bin\../lib/gcc/mingw32/4.4.0/include/stdarg.h
--- MORE LINES HERE ---
mingw32-make.exe[1]: `precmp.h.gch' is up to date.
Make sure you have read the HOW TO POST thread