Removing quotations from linking command

General questions regarding the usage of CodeLite
uMinded
CodeLite Curious
Posts: 3
Joined: Sun Jan 16, 2011 8:02 am
Genuine User: Yes
IDE Question: C++
Contact:

Removing quotations from linking command

Post by uMinded »

I just recently discovered CodeLite and like it quite a bit! I'm use to using VisualC++ and Keil uVision on windows but on linux your left with Code::Blocks (Very hard to customize and how it handles sources), MonoDevelop (Wont even run on Ubuntu..), Eclipse (Horribly clumsy and java based). Now that I got that out of the way I am having a few issues customizing CodeLite for my compiler.

The main issue is that my compiler does not allow quotations in is command line so "-I ." is illegal. Also my compiler does not want stripped library names as it looks for exactly what you specify. If you want libm.a thats that I need to have on the command line. I can easily just add this to the linker options manually and not worry but the quotations are a big issue.

I have a custom makefile that compiles my code perfectly so I have a baseline to setup CodeLite with a little help. Here is my makefile:

Code: Select all

# ARM-MDK toolchain setup
# -------------------------------------------------------------------------------------------------
KEIL_DIR      = /home/uminded/.wine/drive_c/Keil/ARM
TOOLCHAIN_DIR = $(KEIL_DIR)/BIN40
SYS_INC      = -I $(KEIL_DIR)/RV31/INC
SYS_LIB       = $(KEIL_DIR)/RV31/LIB

CC = $(TOOLCHAIN_DIR)/armcc.exe
AS = $(TOOLCHAIN_DIR)/armasm.exe
AR = $(TOOLCHAIN_DIR)/armar.exe
LD = $(TOOLCHAIN_DIR)/armlink.exe
CP = $(TOOLCHAIN_DIR)/fromelf.exe
# -------------------------------------------------------------------------------------------------


# CMSIS & Standard Firmware Library directories
# -------------------------------------------------------------------------------------------------
CMSIS_DIR     = ./lib/STM32F10x_StdPeriph_Lib_V3.4.0/Libraries/CMSIS.2
STARTUP_DIR   = $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/startup/arm
STDPERIPH_DIR = ./lib/STM32F10x_StdPeriph_Lib_V3.4.0/Libraries/STM32F10x_StdPeriph_Driver

INCLUDES     += -I $(CMSIS_DIR)/CM3/CoreSupport
INCLUDES     += -I $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
INCLUDES     += -I $(STDPERIPH_DIR)/inc
# -------------------------------------------------------------------------------------------------


# Here is the list of locations to your source files
# -------------------------------------------------------------------------------------------------
VPATH         = $(CMSIS_DIR)/CM3/CoreSupport
VPATH        += $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
VPATH        += $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/startup/arm
VPATH        += $(STDPERIPH_DIR)/src
VPATH        += ./src/
# Include obj dir so make does not rebuild everything unneccicarly
VPATH        += ./obj/
# -------------------------------------------------------------------------------------------------


# Project setup
# -------------------------------------------------------------------------------------------------
DEFINES       = -D STM32F10X_MD
DEFINES      += -D USE_STDPERIPH_DRIVER

INCLUDES     += $(SYS_INC)
INCLUDES     += -I ./src
INCLUDES     += -I $(CMSIS_DIR)/CM3/CoreSupport
INCLUDES     += -I $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
INCLUDES     += -I $(STDPERIPH_DIR)/inc

CPP_SRC       = main.c
CPP_SRC      += stm32f10x_it.c
CPP_SRC      += core_cm3.c
CPP_SRC      += system_stm32f10x.c
CPP_SRC      += stm32f10x_gpio.c
CPP_SRC      += stm32f10x_rcc.c

CPP_OBJ       = $(CPP_SRC:.c=.o)

ASM_SRC       = startup_stm32f10x_md.s 
ASM_OBJ       = $(ASM_SRC:.s=.o)

DEPENDS       = $(addprefix ./obj/, $(patsubst %.o,%.d, $(ASM_OBJ) $(CPP_OBJ)))

OBJECTS       = $(addprefix ./obj/, $(ASM_OBJ) $(CPP_OBJ))
# -------------------------------------------------------------------------------------------------


# Make directives, recipes, whatever you like to call them...
# -------------------------------------------------------------------------------------------------
.PHONY : all scatter noscatter link_scatter link_noscatter copy clean

scatter : $(CPP_OBJ) $(ASM_OBJ) link_scatter copy

noscatter : $(CPP_OBJ) $(ASM_OBJ) link_noscatter copy

$(CPP_OBJ) : %.o : %.c
	@echo -e "\n Compiling $@ ... \n"
	$(CC) --cpu Cortex-M3 -g -O0 --apcs=interwork --split_sections \
	$(INCLUDES) $(DEFINES) --depend ./obj/$*.d -o ./obj/$@ -c $<
	@echo -e "\n done ... \n"

$(ASM_OBJ) : %.o : %.s
	@echo -e "\n Assembling $@ ... \n"
	$(AS) --cpu Cortex-M3 -g --16 --apcs=interwork $(INCLUDES) --xref \
	--depend ./obj/$*.d -o ./obj/$@ $<
	@echo -e "\n done ... \n"

link_scatter : $(CPP_OBJ) $(ASM_OBJ)
	@echo -e "\n Linking project image ... \n"
	$(LD) --cpu Cortex-M3 ./obj/*.o --libpath $(SYS_LIB) \
	--strict --scatter ./prj/test.sct --autoat \
	--info summarysizes --map --xref --callgraph --symbols \
	--info sizes --info totals --info unused --info veneers \
	--list ./lst/test.map -o ./img/test.axf
	@echo -e "\n done ... \n"

link_noscatter : $(OBJECTS)
	@echo -e "\n Linking project image ... \n"
	$(LD) --cpu Cortex-M3 ./obj/*.o --libpath $(SYS_LIB) --strict \
	--ro-base 0x08000000 --rw-base 0x20000000 --first="startup_stm32f10x_md.o(RESET)" \
	--autoat --info summarysizes --map --xref --callgraph --symbols \
	--info sizes --info totals --info unused --info veneers \
	--list ./lst/test.map -o ./img/test.axf
	@echo -e "\n done ... \n"

copy : ./img/test.axf
	@echo $(OBJECTS)
	@echo $(DEPENDS)
	@echo -e "\n Translating To Binary ... \n"
	$(CP) ./img/test.axf --bincombined --output ./img/test.bin
	@echo -e "\n done ... \n"

clean :
	@echo -e "\n Removing Old Files ... \n"
	-rm ./img/*
	-rm ./lst/*
	-rm ./obj/*
	@echo -e "\n done ... \n"
Currently I have all the linker and compiler options defined in the project settings and .c files compile without errors however the linker can not deal with the "-L." I changed the -L in the build settings -> switches to --userlibpath and now it shows up as "--userlibpath ." but those quotations are killing me. Is their any way to have CodeLite NOT include the "." directory search and only include what I explicitly define?
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Removing quotations from linking command

Post by eranif »

You can not achieve that in the current codelite.

However, I changed this behavior in trunk so that the following will be used:
- If the path includes a space in the name wrap the path with quotation marks (but not the switch itself)
- If there is no space in the path, don't wrap anything

So you can build your own codelite (not too hard...):

- Check out codelite sources from here:

Code: Select all

svn co https://codelite.svn.sourceforge.net/svnroot/codelite/trunk codelite-src
- Download codelite with wxWidgets bundled from here:
http://sourceforge.net/projects/codelit ... e/download
- Load the workspace codelite-src/LiteEditor.workspace
- Hit F7 and wait for the build to end
- Once the build ended, close codelite, open CMD.EXE and navigate to:
codelite-src/Runtime/

and run:
update.bat

Start codelite

Eran
Eran
Make sure you have read the HOW TO POST thread
uMinded
CodeLite Curious
Posts: 3
Joined: Sun Jan 16, 2011 8:02 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Removing quotations from linking command

Post by uMinded »

I understand why you added the wrap with quotations as without them you would need the \ escape sequence before every space. The problem I have is the whole command including the switch is wrapped in quotations regardless of spaces in the path. I am using 2.7.0.4375 but will upgrade to the trunk now.

An update on the library issue I found out that if you double the lib and .a it only strips on off so liblibstm32f10x.a.a turns into lib32f10x.a on the command line. I will try and add under build settings -> switches the ability to have a wildcard so for libraries you can put lib*.a That way the standard behavior stays the same but you can do a bit more with it.

As for the default to search the '.' directory on every single command that is just annoying. If you have any project of any size you do not keep source files in the same directory as the project files so it is useless. Ill put a check box under build settings -> build options to remove '.' search.

Under project settings -> general I would also like to add the ability to change the directories that objects and images get put in as I organize things quite a bit and having 100+ files in one directory is a mess

That being said I garentee nothing lol I'm an embeded programmer and linux programming is new to me.

EDIT:
I installed the 2.9 version from sf.net and their is the additional includes option in the project where I can remove the '.' so I guess someone else found it annoying too.

I just tried to build CodeLite from the trunk and wow thats a few lines of code... It outputs an windows executable though, how do you change it to a linux package?? I have never played with a project his large before.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Removing quotations from linking command

Post by eranif »

uMinded wrote:It outputs an windows executable though, how do you change it to a linux package??
Since you built codelite under Windows, it outputs a windows executable.

For Linux, follow the instructions here (you need to build it under Linux machine ofc):
http://codelite.org/LiteEditor/Download

Search for: "CodeLite from source"

Eran
Make sure you have read the HOW TO POST thread
uMinded
CodeLite Curious
Posts: 3
Joined: Sun Jan 16, 2011 8:02 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Removing quotations from linking command

Post by uMinded »

I did not build it on windows. I am running Linux Mint 10.

I did an svn checkout and the normal './configure && make' builds a Linux binary but when I open it as a project and do the build it creates a windows one. Also when you run 'make clean' it does not remove the binaries from the ./Release/ directory other than checking time stamps to see if it was actually built correctly It's hard to tell. Is it normal for clean not to remove the binaries?

Running ./Release/codelite gets me the spash screen but then it crashes. Is their any special configure options I should be passing?
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Removing quotations from linking command

Post by eranif »

When you build codelite on Linux from within codelite, you should make sure to select the workspace configuration 'Unix_Custom_Makefile'
Otherwise, you will build the default WinReleaseUnicode build configuration.

The configuration is set from the drop-down box on top of the workspace pane.

Once the build is ended, close codelite and run: make install

Eran
Make sure you have read the HOW TO POST thread
Post Reply