Page 1 of 1

New Executable Project with gnu gcc --> files with .cpp ext.

Posted: Sun Oct 26, 2008 2:39 am
by Ice_Blade
I just installed CodeLite on Ubuntu today, and was playing around with it.
I wanted to create a new C executable project, and I like the way the IDE works, but when I tried to build and run the project I got an error.

Code: Select all

Building: 
"make"  -j 1 -f "Maurice_wsp.mk"
----------Building project:[ HelloWorld2 - Debug ]----------
gcc -c  "/home/Maurice/.codelite/Maurice/HelloWorld2/main.cpp" -g  -o ./Debug/main.o -I. 
gcc -o ./Debug/HelloWorld2 ./Debug/main.o    
./Debug/main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make[1]: *** [Debug/HelloWorld2] Error 1
make: *** [All] Error 2
0 errors, 0 warnings, total time: 00:00:00 seconds
----------Build Ended----------
This is caused by gcc recognizing the source's .cpp extension and 'guessing' it is a c++ file.
If I change the file extension to .c, Clean, and try to compile it works correctly.

Now I was wondering why C files get the cpp extension by default, and whether there is an option somewhere to change that to .c ?

Thanks!

Re: New Executable Project with gnu gcc --> files with .cpp ext.

Posted: Sun Oct 26, 2008 3:40 am
by eranif
If u used the templates files, they produce C++ files.
However, you can:
right click on a virtual folder and select 'new item' select the file to be .c

OR

right click on the .cpp file and rename it to be .c

Another option:

- Create new 'executable' project
- right click on the 'main.cpp' file which was generated by CL and rename it to main.c
- right click on the project and change the compiler to be 'gnu gcc'
- right click on the project, and select 'save as template' - name it 'c-executable' - from this point, you will be able to create new projects of type c-executable

Eran

Re: New Executable Project with gnu gcc --> files with .cpp ext.

Posted: Sun Oct 26, 2008 4:09 am
by Ice_Blade
Ok, thanks for the fast reply. :D

I was mostly wondering why the default New Executable Project created a .cpp file when the gcc compiler was selected.
(I assumed it would know gcc was for C files and g++ is for C++ files, especially as the main.cpp file that gets created contains C (style) code.)
I'm not really a great C programmer and know very little c++. I didn't know c++ code used the same headers etc.

Now 1 more question. :)
Is it possible to edit the templates themselves? (Change their settings and/or change the order they appear in the New Project menu?)
Edit: ah I just found the /templates/projects directory so the changing their settings part is covered, just the reorder question remains... ;)

thanks again!

Greetings from Holland.

Re: New Executable Project with gnu gcc --> files with .cpp ext.

Posted: Sun Oct 26, 2008 9:00 am
by eranif
the order is lexicographic (order by a-z), case in-sensitive.

So, if you name your template to 'A C-executable' it will be placed first :)

Eran