Is there a way to invoke another compiler that is different then the entire project?
Here is my example. I have a C++ project, but I have one file in the project that is just C and CodeLite is compiling it with g++. This is not what I expected and was wondering if this can be changed to allow what compiler is used to be set on a file level.
Thanks.
Allow different compilers in a single project
-
- CodeLite Enthusiast
- Posts: 10
- Joined: Tue Sep 02, 2008 7:48 pm
- Contact:
Allow different compilers in a single project
--
Regards,
Ryan
Regards,
Ryan
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Allow different compilers in a single project
Hi Ryan,
When u choose compiler for a project what it actually does it sets the $(CompilerName) variable to be the selected compiler.
Which is then replaced when creating the build rules for the makefile.
To override this behavior, i.e. to set a different compiler do this:
- assuming that you are using 'gnu g++' compiler
- open the compiler settings from: settings -> build settings -> compilers tab
- select the 'File Type' entry for the selected compiler
- replace the line for the 'C' extension from
to
This will invoke the 'C' compiler for 'C' files.
Eran
When u choose compiler for a project what it actually does it sets the $(CompilerName) variable to be the selected compiler.
Which is then replaced when creating the build rules for the makefile.
To override this behavior, i.e. to set a different compiler do this:
- assuming that you are using 'gnu g++' compiler
- open the compiler settings from: settings -> build settings -> compilers tab
- select the 'File Type' entry for the selected compiler
- replace the line for the 'C' extension from
Code: Select all
$(CompilerName) $(SourceSwitch) "$(FileFullPath)" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)
Code: Select all
gcc $(SourceSwitch) "$(FileFullPath)" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 10
- Joined: Tue Sep 02, 2008 7:48 pm
- Contact:
Re: Allow different compilers in a single project
Perfect!
Do you think this could/should be set by default. There is hardly a time, that I can think of, to treat C files as C++.
Do you think this could/should be set by default. There is hardly a time, that I can think of, to treat C files as C++.
--
Regards,
Ryan
Regards,
Ryan
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Allow different compilers in a single project
By keeping $(CompilerName) you allow users to use the value set in the tools chain.
Eran
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Enthusiast
- Posts: 10
- Joined: Tue Sep 02, 2008 7:48 pm
- Contact:
Re: Allow different compilers in a single project
I agree, but if you have a program that has both C and C++ source what are you suppose to do in a multi-user case. It seems hard for me to tell my team to set this setting each time they install CodeLite. To make this clearer, if I have an Open Source project that uses CodeLite then any number of developers will need to set this before being able to build that application.eranif wrote:By keeping $(CompilerName) you allow users to use the value set in the tools chain.
Eran
--
Regards,
Ryan
Regards,
Ryan
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Allow different compilers in a single project
Once installed and changed codelite will not modify your settings even after upgrade. The settings are saved into the user settings and those are not modified by the installer so it is really a one time mission.RJP Computing wrote:It seems hard for me to tell my team to set this setting each time they install CodeLite
You could add this line to the wiki of your OS project:
Eran...
- install codelite
- change $(CompilerName) to gcc for 'C' extension
...
Make sure you have read the HOW TO POST thread