Code::Blocks Forums

User forums => Help => Topic started by: alereche on October 16, 2015, 04:23:11 am

Title: How to edit the command to compile C files within C::B?
Post by: alereche on October 16, 2015, 04:23:11 am
Hello!

I am running C::B on Ubuntu 14.10, using gcc compiler for C programming purposes only.

The way things as configured, the gcc command generates a file with a ".o" extension. After, it seems to be passed to g++ in order to generate the executable file (without any extension, on Linux).

How can I edit this command on C::B in the following simple manner?


> gcc file.c -o file


Furthermore, once I execute this command on a terminal and generate the executable on the proper folder, C::B reads and runs it!

I think there is no problem in having only gcc and not having g++ compiler. (BTW, it seems impossible to download it on my distribution, for some dependence reasons.) So it will be fantastic just to reconfigure C::B to use only gcc.

Best regards,

Alex

P. S. I passed the day searching for this without any success. Thanks in advance.
Title: Re: How to edit the command to compile C files within C::B?
Post by: Scr3amer on October 16, 2015, 04:27:20 am
Yo buddy,

To use gcc instead of g++ for linking part, you can modify that by editing the linker program.

Settings>Toolchain executables tab>linker for dynamics libs , you erase g++ and write gcc.

It will still be a 2 steps compilation though : .c -> .o -> executable.

EDIT :

But you wont be able to compile C++ projects anymore.
If you want to do something cleaner, you can copy the GCC compiler profile, rename it a meaningful way (Exclusive C compiler - GCC for instance) and set your project for using this compiler profile.
Right click on your project > build options and select it ^^.

That way, if one day you do C++ project, you will just have to select the original GCC compiler profile.
Title: Re: How to edit the command to compile C files within C::B?
Post by: alereche on October 16, 2015, 05:14:21 am
Beautiful solution!

Long live to Scr3amer!

Alex