Page 1 of 1

Quite confused using Codelite

Posted: Thu May 14, 2009 3:43 am
by Tigers!
Dear all
I have been trying to use Codelite but without much success. I am confused as to what to do, when to do it and some terminology.
- What is the heirarchy of program/project and workspace?

Initially I am just running a simple program to read in a file and display it but I am getting all sorts of errors. I want to make/build/run it as a C program but I suspect that my various settings are up the creek.

My code is called readRPTfile.c (well I hope it is). It is below

Code: Select all

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *argv[])
{
	FILE *inputFile;
	char c,cc;

	inputFile = fopen("20090220085501237.RPT", "r"); //fopen("file name","mode i.e r-read");
	printf("File opened successfully. Contents:\n\n");

	while ((c=getc(inputFile))!=EOF)
	 { //loop for reading a char up to end of file
		while ((cc=getc(inputFile))!='\n') { // loop for reading a char up to end of line
			putchar(cc); // to display line
		}
	}
	printf("\n\nNow closing file...\n");
	fclose(inputFile);
}
I have the code on my C: drive in a folder called ScanImages. But the Codelite seems to make other folders called ScanImages under each other and puts various files everywhere. See attachment called readRPT.c_folderview.jpg.

My workspace within CodeLite looks like attachment called readRPT.c_workspace.jpg. The worst part is that I have no idea which ScanImages folder Codelite thinks it is in when it runs.

After writing my code and making sure that the source file 20090220085501237.RPT is in the right location to me (but I do not know where CodeLite thinks it is) I use the Run Active project button. See attachment called RunActiceProjectbutton.jpg

A DOS command window appears that says 'Press any key to continue ..'. I do so and the window disappears.

Under the Output View pane the following occurs
- Build tab is empty
- Errors tab is empty
- Find Results tab is empty
- Replace Results tab is empty
- Output tab has the contents

Code: Select all

Current working directory: C:\ScanImages\Scan Images\ScanImages
Running program: le_exec.exe ./ScanImages 
Program exited with return code: 2293464
- Debug tab is empty
- Trace tab has the contents (note the 6th line)

Code: Select all

09:04:19: Loaded plugin: Gizmos Plugin - a collection of useful utils for C++
09:04:19: Loaded plugin: Snippet wizard
09:04:20: Loaded plugin: Subversion
09:04:20: Loaded plugin: A Unit test plugin based on the UnitTest++ framework
09:04:20: Loaded plugin: wxFormBuilder integration with CodeLite
09:04:20: File: C:\ScanImages\Scan Images\readRPTfile.cpp does not exist!
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C/config/accelerators.conf.default'
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C\plugins\resources\abbreviation.accelerators'
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C\plugins\resources\external_tools.accelerators'
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C/config/accelerators.conf.default'
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C\plugins\resources\abbreviation.accelerators'
09:04:20: Loading accelerators from 'C:\Program Files\CodeLite C\plugins\resources\external_tools.accelerators'
09:04:21: Install path: C:\Program Files\CodeLite C
09:04:21: Startup Path: C:\Program Files\CodeLite C
- All the rest of the tabs are empty

Why is it looking for a ccp file? I have saved my file as .c file.
Do I need to use the Build Active project button 1st?
I do hope I have all the modules I need and they are installed properly.

The given documentation assumes or presupposes an awful lot of knowledge that I do not seem to have. (Maybe I need a another, less comprehensive C coder to begin with?)

Re: Quite confused using Codelite

Posted: Thu May 14, 2009 9:42 am
by eranif
Tigers! wrote:- What is the heirarchy of program/project and workspace?
The highest level is the 'Workspace' which is a collection of projects. Each project can produce:
- Executable
- Static library (.a)
- Dynamic Library (.dll)

You can also define relations between projects, for example:
- In order to build project A, Please build project B first, and in codelite terminology it is called 'Dependencies'

In the workspace, there is one project which is set to be active (its name will be in BOLD font), so when u click 'Build' or 'Run' it will build the active project.
Tigers! wrote:But the Codelite seems to make other folders called ScanImages under each other and puts various files everywhere. See attachment called readRPT.c_folderview.jpg.
When you create a new project from the 'Workspace -> Create New Project' menu entry, there is a checkbox that is saying 'Create the project under a separate directory' - this is checked by default, and you should uncheck it if you dont want codelite to create another directory on the disk.

The common way of making a project, is by:
1) Create new workspace from 'Workspace -> Create new workspace' - like the project, this dialog also has a checkbox that creates a separate directory, uncheck it if you dont want it
2) Create new project from 'Workspace -> Create New project' - in your case, select 'executable' as the project type. If you wish to use gcc instead of g++, change in the 'New project dialog'. NOTE:
the template of the 'executable' project will create project with main.cpp file, after the project is created, you can right click on the file (from the 'Workspace' tab to the left) and rename it to whatever you want
3) Copy paste your code, and hit F7

Important notes:
* DO NOT place your workspace under paths which includes space in their name - GDB and in some cases, GCC cant handle it properly.
* DO NOT use workspace names with spaces (use underscores, hyphen instead)
* DO NOT use project names with spaces (use underscores, hyphen instead)


Hope it helped.

Eran

Re: Quite confused using Codelite

Posted: Tue May 26, 2009 11:23 am
by Tigers!
Dear Eran
I have done your suggestions and it seems easier to use and follow now. Thank you.

Some more questions
1. I note that when I use F7 a Debug folder is created that has the files main.o, main .o.d and ScanImagesCleanUp.exe in it. The ScanImagesCleanUp.exe is the executable created from my project called ScanImagesCleanUp. Is this correct? I used the default main.cpp as my test program. In a command window I could run ScanImagesCleanUp.exe and received the message 'Hello World' which was encouraging.

2. I added another file called au_picklist.cpp to that project and tried F7 (main.cpp was still open on another tab). All that seemed too happen is that ScanImagesCleanUp.exe was updated with the new time. I was expecting to see different files appear in the Debug folder. Also I note that in the Workspace View frame the path is ScanImagesTesting -> ScanImagesCleanUp -> src -> main.cpp. I cannot see src a sa folder or a file so am uncertain as to its visiibility and purpose. Also au_picklist.cpp does not appear. Should all open files appear in the Workspace View frame? If not how do i get Codelite to run other files apart from main.cpp? You had noted that main.cpp could be renamed. If we rename it will it appear in the Workspace View frame? does this mean we are limited to only 1 open file at a time? Still a little puzzled.

Re: Quite confused using Codelite

Posted: Tue May 26, 2009 12:12 pm
by eranif
Tigers! wrote:1. I note that when I use F7 a Debug folder is created that has the files main.o, main .o.d and ScanImagesCleanUp.exe in it. The ScanImagesCleanUp.exe is the executable created from my project called ScanImagesCleanUp. Is this correct? I used the default main.cpp as my test program. In a command window I could run ScanImagesCleanUp.exe and received the message 'Hello World' which was encouraging.
Yes, it is correct.
Tigers! wrote:I added another file called au_picklist.cpp to that project and tried F7
How did u add the file?
Tigers! wrote:Also I note that in the Workspace View frame the path is ScanImagesTesting -> ScanImagesCleanUp -> src -> main.cpp. I cannot see src a sa folder or a file so am uncertain as to its visiibility and purpose
The 'src' folder that you see in the workspace view, is a 'virtual folder' its soul purpose is to provide the user with a way to organize its sources.
Tigers! wrote:Also au_picklist.cpp does not appear
You need to add the file to the project y right click on a virtual folder (.e.g 'src') and select 'add an existing items' and select the files that you wish to add
Tigers! wrote:Should all open files appear in the Workspace View frame? If not how do i get Codelite to run other files apart from main.cpp?
Add them to the project (see my previous comments)
Tigers! wrote:Does this mean we are limited to only 1 open file at a time? Still a little puzzled
Obviously not. You just need to understand the basic concept behind workspace / project.

Eran

Re: Quite confused using Codelite

Posted: Thu May 28, 2009 3:44 am
by Tigers!
Eran
I have added the new file like you suggested and now see 2 files: main.cpp & AU_PICKLIST.cpp. So far well and good.
When I try to build AU_PICKLIST.cpp using F7 the build pane notes the following

Code: Select all

----------Build Started--------
"mingw32-make.exe"  -j 2 -f "ScanImagesTesting_wsp.mk"
----------Building project:[ ScanImagesCleanUp - Debug ]----------
gcc -o ./Debug/ScanImagesCleanUp ./Debug/main.o ./Debug/AU_PICKLIST.o    
./Debug/AU_PICKLIST.o: In function `main':
C:/ScanImages/AU_PICKLIST.cpp:5: multiple definition of `main'
./Debug/main.o:C:/ScanImages/main.cpp:4: first defined here
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/ScanImagesCleanUp] Error 1
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------
0 errors, 0 warnings
I am assuming that the multiple definitions of 'main' refers to the fact that I have the 2 files present. How do we get codelite to work only with the file I want under the project that is enboldened (called ScanImagesCleanUp)?
In the debug folder I have .o and .o.d files for both main.cpp & AU_PICKLIST.cpp. Yet before I tried to build AU_PICKLIST.cpp I had a exe called ScanImagesCleanUp.exe which is now gone. The name of that file is presumably related to the project name. I do not know what happened to the exe file. There are no exes present at all.
What I assume would happen is to have a series of exe that have the names of my cpp e.g. number1.exe , number2.exe etc: Is tat how it works or will it only create the single exe that have the name of the project as it's name?
multiplemaindefns.jpg

Re: Quite confused using Codelite

Posted: Thu May 28, 2009 10:36 am
by eranif
Tigers! wrote:I am assuming that the multiple definitions of 'main' refers to the fact that I have the 2 files present
It means that your application has to 'main' functions. all the files under the same project are compiled into a one executable (in your case).

You could:
- Remove the file from that you dont want from the project (why is it there in teh first place??)
- Create a new project and add that file to it

If you wish to create 2 executables, you need yo create 2 projects and add to each project the sources files that are related to it.

Eran