how to setup options for compiler

CodeLite installation/troubleshooting forum
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

hbr_in wrote:Why 3 options provided. Isnt the 2nd & 3rd the same. Isnt 1st & 2nd enough for all purpose. Since i havent seen such a situation, i would like to know where it is or will be used.
ReBuild=Clean followed by Build
It is not really the same, assuming you have a large project, clean can take some time, so u clicked 'Clean' and then you need to *wait* and then do the 'Build'
Rebuild does the waiting for you...

Regarding the problem:
Can u try to run 'Build' (F7 or project context meun -> Build) and not 'Compile' from file context menu.
The problem is:

The 'Change directory' is not respected for single file compilation only - how ever it is respected for project build.

I found this in the code:

Code: Select all

//when using custom build, user can select different working directory
		if (isCustom) {
			//first set the path to the project working directory
			::wxSetWorkingDirectory(proj->GetFileName().GetPath());
			BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration());
			if (buildConf) {
				wxString wd = buildConf->GetCustomBuildWorkingDir();
				if (wd.IsEmpty()) {
					// use the project path
					wd = proj->GetFileName().GetPath();
				}else { 
					// expand macros from path
					wd = ExpandAllVariables(wd, WorkspaceST::Get(), proj->GetName(), buildConf->GetName(), wxEmptyString);
				}
				::wxSetWorkingDirectory(wd);
			}
		}
At this point the working directory is set correctly, however, later in the code:

Code: Select all

if (m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) {
			//need to change directory to project dir
			::wxSetWorkingDirectory(proj->GetFileName().GetPath());
..
...
Which overrides the previous working directory

Please open a bug about this: 'Custom build & compile single file does not honors the working directory set'

Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

eranif wrote:
hbr_in wrote:Why 3 options provided. Isnt the 2nd & 3rd the same. Isnt 1st & 2nd enough for all purpose. Since i havent seen such a situation, i would like to know where it is or will be used.
ReBuild=Clean followed by Build
It is not really the same, assuming you have a large project, clean can take some time, so u clicked 'Clean' and then you need to *wait* and then do the 'Build'
Rebuild does the waiting for you...
.
I knew the diff b/w rebuild & clean but I meant why options are given at 3 diffrent places for same command.

1. Build/Clean/Rebuild Wokspace -> in Context menu from Right Click on workspace
2. Build/Clean/Rebuild ->in Context menu from Right Click on project
3. Project only Build/Clean.

Why 3 options provided. Isnt the 2nd & 3rd the same. Isnt 1st & 2nd enough for all purpose. Since i havent seen such a situation, i would like to know where it is or will be used.

Regards
Gururaja
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

any updates on this

In Workspace tab - project "prj_bootloader" - right click -> Settings window, i changed IntermediateDirectory to point to "C:/prj/sd_fat/testing/bootloader/prj/Release". When i select compile from src file->right click context menu i get below error

Building: "C:/cygwin/bin/make.EXE" -j 2 -f "prj_bootloader.mk" type=Release C:/prj/sd_fat/testing/bootloader/prj/Release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
prj_bootloader.mk:60: *** target pattern contains no `%'. Stop.
----------Build Ended----------


Regards
Gururaja
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

and also this

1. In the Coonfiguration Manager window, For Workspace Configuration, i get only "Debug, <New>, <Edit>" options. No Release Option. Do i need to set something to get Release as default Configuration Type for all projects


Regards
Gururaja
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

hbr_in wrote:I knew the diff b/w rebuild & clean but I meant why options are given at 3 diffrent places for same command.
They are not the same.
Project -> Build - builds the current project and its dependencies. If a project exists in the workspace, and does not associated to the project being built (from project context menu -> Build Order)
It will not get builded.

Workspace -> Build Builds *ALL* projects. it starts to build them in order of appearance, each project is then built with its dependencies. So at the end of the process, all projects are built.

project only -> Build --> builds the project without any of its dependencies.

An example:
Assuming you have workspace 'WSP' with PRJ1, PRJ2 and PRJ3

Now, assuming that PRJ1 is the active project, and in its build order it is set that PRJ3 should be built first.

So:
Workspce context menu -> Build will perform this:
PRJ3 -> PRJ1 and then PRJ2 - note that PRJ3 is built first, since it is depends on PRJ1

Project PRJ1 context meun -> Build:
PRJ3 -> PRJ1 --> note that PRJ2 is not built here, since it is not related to PRJ1

Project PRJ1 context menu -> Project Only -> Build
only PRJ1 is built.
hbr_in wrote: Building: "C:/cygwin/bin/make.EXE" -j 2 -f "prj_bootloader.mk" type=Release C:/prj/sd_fat/testing/bootloader/prj/Release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
prj_bootloader.mk:60: *** target pattern contains no `%'. Stop.
----------Build Ended----------
Can u provide the makefile?

Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

[quote="eranif
hbr_in wrote: Building: "C:/cygwin/bin/make.EXE" -j 2 -f "prj_bootloader.mk" type=Release C:/prj/sd_fat/testing/bootloader/prj/Release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
prj_bootloader.mk:60: *** target pattern contains no `%'. Stop.
----------Build Ended----------
Can u provide the makefile?
Eran[/quote]

I cannot attach any files. What extension are allowed?

I pasting the contents of file that i think is neccessary

codelite_wrkspc_wsp.mk

Code: Select all

.PHONY: clean All

All:
	@echo ----------Building project:[ prj_bootloader - Release ]----------
	@cd "prj_bootloader" && "C:/cygwin/bin/make.EXE"  -j 2 -f "prj_bootloader.mk" type=Release 
clean:
	@echo ----------Building project:[ prj_bootloader - Release ]----------
	@cd "prj_bootloader" && "C:/cygwin/bin/make.EXE"  -j 2 -f "prj_bootloader.mk" type=Release  clean

codelite_wrkspc.workspace

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<CodeLite_Workspace Name="codelite_wrkspc" Database=".\codelite_wrkspc.tags">
  <Project Name="prj_bootloader" Path="prj_bootloader\prj_bootloader.project" Active="Yes"/>
  <BuildMatrix>
    <WorkspaceConfiguration Name="Debug" Selected="yes">
      <Project Name="prj_bootloader" ConfigName="Release"/>
    </WorkspaceConfiguration>
  </BuildMatrix>
</CodeLite_Workspace>
prj_bootloader.project

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<CodeLite_Project Name="prj_bootloader">
  <Description/>
  <Dependencies/>
  <VirtualDirectory Name="src"/>
  <VirtualDirectory Name="working">
    <VirtualDirectory Name="src">
      <File Name="..\..\..\..\..\..\..\..\prj\sd_fat\testing\bootloader\working\command.c"/>
      <File Name="..\..\..\..\..\..\..\..\prj\sd_fat\testing\bootloader\working\common.c"/>
    </VirtualDirectory>
    <VirtualDirectory Name="headers">
      <File Name="..\..\..\..\..\..\..\..\prj\sd_fat\testing\bootloader\working\command.h"/>
      <File Name="..\..\..\..\..\..\..\..\prj\sd_fat\testing\bootloader\working\common.h"/>
    </VirtualDirectory>
    <VirtualDirectory Name="others">
      <File Name="..\..\..\..\..\..\..\..\prj\sd_fat\testing\bootloader\working\int_is.s"/>
    </VirtualDirectory>
  </VirtualDirectory>
  <Dependencies Name="Debug"/>
  <Dependencies Name="Release"/>
  <Settings Type="Executable">
    <Configuration Name="Debug" CompilerType="gnu gcc" DebuggerType="GNU gdb debugger" Type="Executable">
      <General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
      <Compiler Required="no" Options="-g">
        <IncludePath Value="."/>
      </Compiler>
      <Linker Required="no" Options=""/>
      <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort=""></Debugger>
      <ResourceCompiler Required="no" Options=""/>
      <PreBuild/>
      <PostBuild/>
      <CustomBuild Enabled="no">
        <CleanCommand></CleanCommand>
        <BuildCommand></BuildCommand>
        <SingleFileCommand></SingleFileCommand>
        <MakefileGenerationCommand></MakefileGenerationCommand>
        <ThirdPartyToolName>None</ThirdPartyToolName>
        <WorkingDirectory></WorkingDirectory>
      </CustomBuild>
      <AdditionalRules>
        <CustomPostBuild></CustomPostBuild>
        <CustomPreBuild></CustomPreBuild>
      </AdditionalRules>
    </Configuration>
    <Configuration Name="Release" CompilerType="cust_compiler" DebuggerType="GNU gdb debugger" Type="Executable">
      <General OutputFile="" IntermediateDirectory="ccwork" Command="./$(ProjectName)" CommandArguments="" WorkingDirectory="C:/prj/sd_fat/testing/bootloader/prj/" PauseExecWhenProcTerminates="yes"/>
      <Compiler Required="yes" Options="-Wundef -Wall"/>
      <Linker Required="yes" Options=""/>
      <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort=""></Debugger>
      <ResourceCompiler Required="no" Options=""/>
      <PreBuild/>
      <PostBuild/>
      <CustomBuild Enabled="no">
        <CleanCommand>runmk -r C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx</CleanCommand>
        <BuildCommand>runmk C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx</BuildCommand>
        <SingleFileCommand>runcc -Wundef,-Wall $(CurrentFileFullPath)</SingleFileCommand>
        <MakefileGenerationCommand></MakefileGenerationCommand>
        <ThirdPartyToolName>None</ThirdPartyToolName>
        <WorkingDirectory>C:\prj\sd_fat\testing\bootloader\prj\Release</WorkingDirectory>
      </CustomBuild>
      <AdditionalRules>
        <CustomPostBuild></CustomPostBuild>
        <CustomPreBuild>

</CustomPreBuild>
      </AdditionalRules>
    </Configuration>
  </Settings>
</CodeLite_Project>


prj_bootloader.mk

Code: Select all

##
## Auto Generated makefile, please do not edit
##
ProjectName:=prj_bootloader

## Release
ifeq ($(type),Release)
ConfigurationName :=Release
IntermediateDirectory :=ccwork
OutDir := $(IntermediateDirectory)
LinkerName:=
ArchiveTool :=ear
SharedObjectLinkerName :=
ObjectSuffix :=.o
DebugSwitch :=-g 
IncludeSwitch :=-I
LibrarySwitch :=-l
OutputSwitch :=-o 
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c 
CompilerName :=runcc
OutputFile :=
Preprocessors :=
ObjectSwitch :=-o 
ArchiveOutputSwitch := 
CmpOptions :=-Wundef -Wall $(Preprocessors)
LinkOptions := 
IncludePath :=  
RcIncludePath :=
Libs :=
LibPath := 
endif

Objects=$(IntermediateDirectory)/command$(ObjectSuffix) $(IntermediateDirectory)/common$(ObjectSuffix)

##
## Main Build Tragets 
##
all: $(OutputFile)

$(OutputFile): makeDirStep PrePreBuild $(Objects)
	@makedir $(@D)
	@pwd
	$(LinkerName) $(OutputSwitch)$(OutputFile) $(Objects) $(LibPath) $(Libs) $(LinkOptions)

makeDirStep:
	@makedir "ccwork"

PrePreBuild: 



PreBuild:


##
## Objects
##
$(IntermediateDirectory)/command$(ObjectSuffix): ../../../../../../../../prj/sd_fat/testing/bootloader/working/command.c
	pwd
	$(CompilerName) $(SourceSwitch) "C:/prj/sd_fat/testing/bootloader/working/command.c" $(CmpOptions)   $(ObjectSwitch)$(IntermediateDirectory)/command$(ObjectSuffix) $(IncludePath)

$(IntermediateDirectory)/common$(ObjectSuffix): ../../../../../../../../prj/sd_fat/testing/bootloader/working/common.c
	pwd
	$(CompilerName) $(SourceSwitch) "C:/prj/sd_fat/testing/bootloader/working/common.c" $(CmpOptions)   $(ObjectSwitch)$(IntermediateDirectory)/common$(ObjectSuffix) $(IncludePath)

##
## Clean
##
clean:
	$(RM) $(IntermediateDirectory)/command$(ObjectSuffix)
	$(RM) $(IntermediateDirectory)/command$(ObjectSuffix).d
	$(RM) $(IntermediateDirectory)/common$(ObjectSuffix)
	$(RM) $(IntermediateDirectory)/common$(ObjectSuffix).d
	$(RM) $(OutputFile)
	$(RM) $(OutputFile).exe

User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

there is something wrong with your settings I think:
CodeLite is trying to build target 'C:/prj/sd_fat/testing/bootloader/prj/Release/common.o'
But there is no such target.

Here you set the IntermdiateDirectory - this is the path where you want CodeLite to place all your objects.

Code: Select all

IntermediateDirectory :=ccwork
The rule in the makefile, according to what you defined:

Code: Select all

$(IntermediateDirectory)/common$(ObjectSuffix)
which will expand into: ccwork/common.o which != C:/prj/sd_fat/testing/bootloader/prj/Release/common.o

Try this:
In IntermediateDirectory place this ('project context menu -> settings ... -> Intermediate Directory'):

Code: Select all

C:/prj/sd_fat/testing/bootloader/prj/Release/
In 'custom build' -> single file command change it to be:

Code: Select all

C:/cygwin/bin/make.EXE -f prj_bootloader.mk type=Release $(IntermediateDirectory)/$(CurrentFileName).o
I am assuming here that you are using the custom build (otherwise, I dont know how you managed to use makefile with 'pwd' inside it)

Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

eranif wrote:there is something wrong with your settings I think:
CodeLite is trying to build target 'C:/prj/sd_fat/testing/bootloader/prj/Release/common.o'
But there is no such target.

Here you set the IntermdiateDirectory - this is the path where you want CodeLite to place all your objects.

Code: Select all

IntermediateDirectory :=ccwork
eranif wrote: The rule in the makefile, according to what you defined:

Code: Select all

$(IntermediateDirectory)/common$(ObjectSuffix)
which will expand into: ccwork/common.o which != C:/prj/sd_fat/testing/bootloader/prj/Release/common.o
This i did because the WorkingDirectory macro was not respected while building/compilling.
eranif wrote:
Try this:
In IntermediateDirectory place this ('project context menu -> settings ... -> Intermediate Directory'):

Code: Select all

C:/prj/sd_fat/testing/bootloader/prj/Release/
In 'custom build' -> single file command change it to be:

Code: Select all

C:/cygwin/bin/make.EXE -f prj_bootloader.mk type=Release $(IntermediateDirectory)/$(CurrentFileName).o
When i did this and gave compile from filename->right click->select compile, i get below error

Code: Select all

Building: C:/cygwin/bin/make.EXE -f prj_bootloader.mk type=Release C:/prj/sd_fat/testing/bootloader/prj/Release//common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
prj_bootloader.mk:60: *** target pattern contains no `%'.  Stop.
----------Build Ended----------
eranif wrote: I am assuming here that you are using the custom build (otherwise, I dont know how you managed to use makefile with 'pwd' inside it)
No i am not using custom build. I edited the make file that is generated by CL. This make file prj_bootloader.mk was placed in the same folder where my project's "prj_bootloader.project" file

My source file(*.c, *.h) files are in C:\prj\sd_fat\testing\bootloader\working
I need the object files to be built inside C:\prj\sd_fat\testing\bootloader\prj\Release

what i need is that, before calling make or executing the custom build command for the entire project or for single file, the Working Directory should be respected. In this case i can set the working directory to C:\prj\sd_fat\testing\bootloader\prj\ & Intermediate directory to release. everything will be as it should be. looking the makefile generated by CL, it seems that working directory macro is not respected for single file build.

If this is not able to be solved/understood, i think we can leave this topic as i think i am eating ur time. For the time being i will manage with the IDE that came with the compiler for compiling & use CL for code editing

Thanks again for your support.

Regards
Gururaja
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

Post Reply