Author Topic: Code Blocks using wrong compiler [Linux]  (Read 16770 times)

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Code Blocks using wrong compiler [Linux]
« on: March 05, 2008, 07:28:47 pm »
Hello, I just installed Code Blocks via yum on Fedora Core 8.  I tried compiling a simple Hello World program, and I get the following error:

'"Test - Debug" uses an invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!]. Skipping...'

After a bit of research, I found that inside the project files XML, the compiler is being set to "gcc", which is the C compiler.  I need this to be g++.  However, according to the compiler settings window (toolchain executable tab), the C++ compiler is set to g++.

So what the problem seems to be is that Code Blocks thinks that my hello world project is a C program.  And try as I might, I can find no project setting (or build target setting, for that matter) which flags the project as a C++ program, or tells it to use a C++ compiler.  I suppose a workaround would involve manually editing the project file and replacing all occurances of 'gcc' with 'g++', but I would really rather avoid editing automatically generated files.

Any suggestions on how to fix this?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Blocks using wrong compiler [Linux]
« Reply #1 on: March 05, 2008, 07:35:04 pm »
in the cbp file it should say gcc, not g++.

Then it depends on the extension : main.cpp or main.c

Could you attach that test project ??

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Re: Code Blocks using wrong compiler [Linux]
« Reply #2 on: March 05, 2008, 07:48:38 pm »
Attached project files (and the hello world program too).

/edit: Renamed the files to have a .txt extension so that forums would allow them to be uploaded, and I'm too lazy to zip them together -.-

/edit2: After some fiddling around (closing code blocks, and restarting it while saving changes to projects), it added a line to the .cbd file:

'      <Unit filename="test.cpp" />'

However, this did nothing to solve my problem...

[attachment deleted by admin]
« Last Edit: March 05, 2008, 07:54:42 pm by Taedrin »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Blocks using wrong compiler [Linux]
« Reply #3 on: March 05, 2008, 07:54:15 pm »
one thing I see in the cbp file, it has no units == there are no source files in the project !!!

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Re: Code Blocks using wrong compiler [Linux]
« Reply #4 on: March 05, 2008, 07:55:46 pm »
Check my edit above, it didn't put that into the cbd file until after I close the IDE and saved changes.  But still didn't fix anything.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code Blocks using wrong compiler [Linux]
« Reply #5 on: March 05, 2008, 08:04:41 pm »
Please change "Settings -> Compiler and Debugger -> Global Compiler Settings -> Other Settings (it's the rightmost tab)  -> Compiler Logging" to "Full command line" and try to compile again.
Then you can post the compilers commandline and/or try the same instruction from console.
Your project compiles fine after adding the source file.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Blocks using wrong compiler [Linux]
« Reply #6 on: March 05, 2008, 08:06:09 pm »
yes, do what Jens says, that was my next advice, but now I don't have to type it myself ;-)

When I added the cpp file to the project you had attached it worked for me.

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Re: Code Blocks using wrong compiler [Linux]
« Reply #7 on: March 05, 2008, 08:18:54 pm »
No change in the error output, though I did find out something interesting.  When I right click on the file and select "build file", no output is produced at all.  It makes me think that instead of the wrong compiler being used, I am simply not adding the file to the project properly.  The way I do this is right-clicking on the project in the navigation pane on the left, and selecting "add file...", selecting "test.cpp", and then selecting both the "Debug" and "Release" build targets.

Am I doing that right?

And as for on the command line, using

'gcc test.cpp -o test' produces a bunch of undefined references to std::ios (since gcc does not compile C++ programs).
'g++ test.cpp -o test' is successful, and running 'test' produces the expected "Hello World!" output.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Blocks using wrong compiler [Linux]
« Reply #8 on: March 05, 2008, 08:22:19 pm »
you adding is correct, put paste the log from cb in the build pane

You should have something like :

Quote

-------------- Build: Debug in Test ---------------

g++ -Wall  -g    -I/usr/bin/include  -c /home/ldc/Desktop/DelMe/test.cpp -o obj/Debug/test.o
g++ -L/usr/bin/lib  -o bin/Debug/Test obj/Debug/test.o   
Output size is 63.67 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings
Build log saved as:
file:///home/ldc/Desktop/DelMe/Test_build_log.html
 
« Last Edit: March 05, 2008, 08:23:58 pm by killerbot »

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Re: Code Blocks using wrong compiler [Linux]
« Reply #9 on: March 05, 2008, 08:27:10 pm »
Build log when building the project:

Quote
"Test - Debug" uses an invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!]. Skipping...
Nothing to be done.

Build log when building the file only:
Quote

(yes, it shows literally *nothing* when building the file only)

/edit: and just to note, I did set the compiler logging to full command-line
« Last Edit: March 05, 2008, 08:29:01 pm by Taedrin »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Blocks using wrong compiler [Linux]
« Reply #10 on: March 05, 2008, 08:39:06 pm »
check in the overal compiler options of CB if it found gcc, maybe the path is not correct !!
Toolchain executables : check path and programs

example of my system :
path : /usr/bin
c compiler : gcc
c++ compiler : g++
....

Offline Taedrin

  • Single posting newcomer
  • *
  • Posts: 6
Re: Code Blocks using wrong compiler [Linux]
« Reply #11 on: March 05, 2008, 08:45:34 pm »
That did it.

Code blocks was looking in /usr/lib/bin
but gcc/g++ was in /usr/lib/ccache.

Added /usr/lib/ccache to additional directories, and compiles like a charm.  Thank you for your time and help in this.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code Blocks using wrong compiler [Linux]
« Reply #12 on: March 05, 2008, 08:50:08 pm »
That did it.

Code blocks was looking in /usr/lib/bin
but gcc/g++ was in /usr/lib/ccache.

Added /usr/lib/ccache to additional directories, and compiles like a charm.  Thank you for your time and help in this.

Nice to hear.

By the way is that the Fedora standard path for gnu compiler suite ?

madopal

  • Guest
Re: Code Blocks using wrong compiler [Linux]
« Reply #13 on: March 07, 2008, 05:45:16 pm »
I've got F8 installed, and I had the same problem.  However, my gcc/g++ are in the more standard path of /usr/bin.  It was looking in /usr/lib for me as well.

Rather unusual place to look for executables.

Offline Trent

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code Blocks using wrong compiler [Linux]
« Reply #14 on: March 09, 2008, 01:49:45 am »
I am having the same problem, i just intsalled code blocks on windows xp and i cant get it to compile.
I am looking in toolchain executables but i am not sure wat to do.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code Blocks using wrong compiler [Linux]
« Reply #15 on: March 09, 2008, 02:08:04 am »
I am having the same problem, i just intsalled code blocks on windows xp and i cant get it to compile.
I am looking in toolchain executables but i am not sure wat to do.

Which version of C::B?

If 8.02 the MinGW-compiler is integrated in installer and should be found at first run of C::B, if you do not install it (MinGW) in a very strange folder.

The textbox "Compilers Installation directory" contains the base-directory of MinGW compiler suite (e.g. "c:\MinGW").
The textareas in "Program Files" should contain the names of the executables  ("gcc.exe" as c-compiler "g++.exe" as c++-compiler and linker for dynamic libs and so on).

Offline Trent

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code Blocks using wrong compiler [Linux]
« Reply #16 on: March 09, 2008, 02:23:50 am »
It is version 8.02 and in the program files for c compiler its has mingw32-gcc.exe and for c++ is has mingw32-g++.exe

Offline Trent

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code Blocks using wrong compiler [Linux]
« Reply #17 on: March 09, 2008, 02:25:59 am »
I followed what you guys told taedron to do and the same things happened to me as what he said accept for when you guys went into toolchain executables i got lost

Offline Trent

  • Single posting newcomer
  • *
  • Posts: 4
Re: Code Blocks using wrong compiler [Linux]
« Reply #18 on: March 09, 2008, 02:32:05 am »
When i go to creat a new project i go Console Application and i choose C++ for the language and i choose
GNU GCC Compiler.   That is wat i have been doing at the school computer but it was using linux. Does that change now that i am using windows?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code Blocks using wrong compiler [Linux]
« Reply #19 on: March 09, 2008, 09:25:25 am »
Can you please do what I wrote here and then post the output of your build log ?

moromete

  • Guest
Re: Code Blocks using wrong compiler [Linux]
« Reply #20 on: March 28, 2008, 08:12:34 am »
just add this directory in Toolchain executables Additional Paths
/usr/lib/ccache



[attachment deleted by admin]