I am new to code::blocks.
I installed cb mingw on a windows 7 machine. I used settings to specify the root directory for the compiler exes and linker settings to specify the path for the include files.
When I tried to compile Hello World (you have to start somewhere) I got a message "fatal error: iostream: no such file or directory".
What am I doing wrong?
Lew
OK I found how to set the path for the include modules and the .h modules.
Now the compile message is "build file: "no target" in CS390 Learning (compiler: GNU GCC compiler)
As far as I can tell the target is set to debug.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Thanks staht01, that helped get me through not finding a .h module.
Now it's blowing up on "namespace std _GLIBCXX_VISIBILITY (default)" which is a line in iostream.
Looks like it's hands on help from the instructor or ...
If you post the full rebuild log; I might be able to see the causes of some simple errors.
For C or C++ programming questions/help I suggest, http://cboard.cprogramming.com/forum.php (http://cboard.cprogramming.com/forum.php)
http://cboard.cprogramming.com/forum.php
Tim S.
A wild guess, your file has ".c" as an extension and not ".cpp" ? Using <iostream> is strictly C++
Yves
The program code is at the bottom.
These compile/build errors (only the first few) are in memoryfwd.h:
-------------- Build: Debug in cb learning (compiler: GNU GCC Compiler)---------------
mingw32-gcc.exe -Wall -g -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++" -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32\bits" -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32" -c "C:\Data\CS 390\code\cb learning\hello.c" -o obj\Debug\hello.o
In file included from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/stringfwd.h:40:0,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iosfwd:39,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ios:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ostream:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iostream:39,
from C:\Data\CS 390\code\cb learning\hello.c:1:
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/memoryfwd.h:50:1: error: unknown type name 'namespace'
namespace std _GLIBCXX_VISIBILITY(default)
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/memoryfwd.h:51:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iosfwd:39:0,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ios:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ostream:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iostream:39,
from C:\Data\CS 390\code\cb learning\hello.c:1:
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/stringfwd.h:42:1: error: unknown type name 'namespace'
namespace std _GLIBCXX_VISIBILITY(default)
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/stringfwd.h:43:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/bits/postypes.h:40:0,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iosfwd:40,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ios:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/ostream:38,
from C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/iostream:39,
from C:\Data\CS 390\code\cb learning\hello.c:1:
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/cwchar:62:1: error: unknown type name 'namespace'
namespace std
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/cwchar:63:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/cwchar:135:1: error: unknown type name 'namespace'
namespace std _GLIBCXX_VISIBILITY(default)
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/cwchar:136:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++/cwchar:241:1: error: unknown type name 'namespace'
namespace __gnu_cxx
^
---------
The code is:
#include <iostream>
using namespace std;
int main()
{
cout << "hello world\n";
return 0;
}
Name the program file with the correct file extension instead of using the name "hello.c" try using "hello.cpp".
Tim S.
I created a new project and named the source hello.cpp. On build I got these errors:
-------------- Build: Debug in test 2 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -g -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++" -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32\bits" -I"C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32" -c "C:\Data\CS 390\code\test 2\hello.cpp" -o obj\Debug\hello.o
mingw32-g++.exe -o "bin\Debug\test 2.exe" obj\Debug\hello.o "C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++" "C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32\bits" "C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32" "C:\Program Files (x86)\CodeBlocks\MinGW\bin"
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++: Permission denied
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32\bits: Permission denied
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.9.2\include\c++\mingw32: Permission denied
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find C:\Program Files (x86)\CodeBlocks\MinGW\bin: Permission denied
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 3 second(s))
5 error(s), 0 warning(s) (0 minute(s), 3 second(s))
I've set the 5 error messages to bold and italic.
thanks
Lew
I found ld.exe in C:\Program Files (x86)\CodeBlocks\MinGW\mingw32\bin and added that path to the global compiler settings. I got the same result except this time there were 6 errors.
Thanks
Lew
Thanks stahta01. I found another post, about permission denied, where you linked to the answer.
I had added directories to the linker setting/link libraries in random attempts to solve my problems. When I removed all the directories, it compiled and ran correctly.
Thanks
Lew
If it is of any help, in order for C:B to find precompiled headers like iostream, you must set up a project and then a program in the project should work fine for all C++ headers.