Code::Blocks Forums
User forums => Help => Topic started by: Taedrin 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?
-
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 ??
-
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]
-
one thing I see in the cbp file, it has no units == there are no source files in the project !!!
-
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.
-
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.
-
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.
-
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.
-
you adding is correct, put paste the log from cb in the build pane
You should have something like :
-------------- 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
-
Build log when building the project:
"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:
(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
-
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++
....
-
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.
-
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 ?
-
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.
-
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.
-
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).
-
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
-
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
-
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?
-
Can you please do what I wrote here (http://forums.codeblocks.org/index.php/topic,7925.msg59436.html#msg59436) and then post the output of your build log ?
-
just add this directory in Toolchain executables Additional Paths
/usr/lib/ccache
[attachment deleted by admin]