News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

CB can't find iostream

Started by msm98lw, June 20, 2016, 05:42:46 PM

Previous topic - Next topic

msm98lw

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

msm98lw

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.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

msm98lw

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 ...

stahta01

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

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

yvesdm3000

A wild guess, your file has ".c" as an extension and not ".cpp" ? Using <iostream> is strictly C++

Yves
Clang based code completion for Code::Blocks:   [url="http://github.com/yvesdm3000/ClangLib"]http://github.com/yvesdm3000/ClangLib[/url]

msm98lw

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;
}

stahta01

Name the program file with the correct file extension instead of using the name "hello.c" try using "hello.cpp".

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

msm98lw

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


msm98lw

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

msm98lw

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

RealHighlander

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.