What should I do when I have two compilers to compile files?

General questions regarding the usage of CodeLite
annci
CodeLite Curious
Posts: 2
Joined: Mon Aug 25, 2008 7:52 am
Contact:

What should I do when I have two compilers to compile files?

Post by annci »

I must compile some cpp files and asm files in one project. Cpp files must be compiled by g++, and asm files must be done by Nasm, I don't know how to choose compiler in Codelite? Or I need to edit new compilter, but how should I edit it? If you know it, please tell me.Thank you very much.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: What should I do when I have two compilers to compile files?

Post by eranif »

From your other post, I saw that you are using custom makefile, if this is the case then there is no problem - just mark the project as custom.

Currently, codelite allows you to set compiler per project. Your best bet is:
1. Define NASM compiler (Settings -> Build Settings ...) and then click on 'New ...' button, give it a name 'nasm' and cick OK, this will create a copy of the 'g++' compiler. Next step is to define the 'Tools', 'General' and 'Switches' tabs. First, at the 'Tools' tab, edit and replace the toolchain (for example: Compiler name: nasm)
In 'General' tab, edit regexes so codelite can parse the compiler output (this is optional, since it is only used to allow you to jump to line/file when error occurs)

2. Create a new project of type 'static library' add all your asm files there, and select the compiler for this project to be the new 'NASM' compiler.

3. In your main project, right click on it, and select 'Build Order...' check the NASM project - so codelite will first build this project and then will compile the C++ code.

Another option:
Use single compiler and project, and define custom makefile rule only for the asm files, to do this:
After you set up your project, right click on it and select the last tab 'Custom makefile steps'

For the sake of the example, I will assume here that you only have 2 asm file :D :

In the 'dependencies' filed, enter:

Code: Select all

$(IntermediateDirectory)/myasm1.o $(IntermediateDirectory)/myasm2.o
and as the 'Rule action':

Code: Select all

$(IntermediateDirectory)/myasm1.o: myasm1.asm
	nasm -f elf myasm1.asm -o $(IntermediateDirectory)/myasm1.o

$(IntermediateDirectory)/myasm2.o: myasm2.asm
	nasm -f elf myasm2.asm -o $(IntermediateDirectory)/myasm2.o
HTH,
Eran
Make sure you have read the HOW TO POST thread
Post Reply