Author Topic: Code::Blocks Choosing Wrong Compiler  (Read 6075 times)

Offline SoBigBoy

  • Single posting newcomer
  • *
  • Posts: 4
Code::Blocks Choosing Wrong Compiler
« on: February 12, 2014, 06:36:16 am »
This may be a bug, or maybe it's just user error.
:)

First I installed MinGW for C (not C++).
Next, I installed Codes::Block 13.12 and created a new project by selecting Console Application
I then selected the C language.

After the project was created, I opened up the .c file containin main() that had the Hello, world in it.  But when I do a build (or rebuid), I get the following error message:
"mingw32-g++.exe  -o bin\Debug\Arrays.exe obj\Debug\main.o   
Execution of 'mingw32-g++.exe  -o bin\Debug\Arrays.exe obj\Debug\main.o' in 'E:\Documents\Documents\CodeBlock C Projects\Arrays' failed."

Code::Blocks is using the wrong compiler.  I do not have mingw32-g++.exe which is a C++ compiler.  I have a mingw32-gcc.exe and a mingw32-cc.exe in the compiler's bin directory.  If I run either of these from the command console, they both show I using (gcc) 4.8.1

I went to settings in Code::Blocks, and it shows I'm using GNU GCC compiler, but it doesn't show me the executable file name or any way to change it.

Can someone tell me how to change it so that it uses the C compiler instead of the C++ compiler?

Thanks.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Code::Blocks Choosing Wrong Compiler
« Reply #1 on: February 12, 2014, 08:15:03 am »
Make sure you select the right executable for the linker than if you intend to only develop in C. I'm afraid the default linker executable is set to g++, but you can change that in the global compiler options easily.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline SoBigBoy

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code::Blocks Choosing Wrong Compiler
« Reply #2 on: February 12, 2014, 09:11:36 pm »
Thank you, MortenMacFly!

I was looking under the Compiler settings and Linker settings.  I didn't realize I needed to look under the Toolchain Executables tab.

For any newbies that have this problem, here are steps to the solution.
Go to Settings, then select Compiler.
Next, select the Toolchain Executables tab.
Change Compiler to mingw32-gcc.exe
Change Linker for dynamic libs to mingw32-gcc.exe
Click Ok.

(Mark this as user error.)
:)