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

CodeLite installation/troubleshooting forum
Ice_Blade
CodeLite Curious
Posts: 2
Joined: Sun Oct 26, 2008 2:04 am
Contact:

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

Post 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!
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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
Make sure you have read the HOW TO POST thread
Ice_Blade
CodeLite Curious
Posts: 2
Joined: Sun Oct 26, 2008 2:04 am
Contact:

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

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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
Make sure you have read the HOW TO POST thread
Post Reply