Sorry to bump an ancient topic, but it was at the top of the list on Google when I searched iostream codeblocks. I was having the same problem and hoped to find a solution, but there was none to be found. All your "MinGW" and "GCC" just confused the hell out of me since I'm completely new to C++ and have no idea what anything is.
The solution is to put your .c file in the same folder you have Code::Blocks installed in. I originally had test.c on my desktop and got the same error shiguy48 did, but it worked perfectly fine when I moved it to C:\Program Files\CodeBlocks and tried it from there.
All your "MinGW" and "GCC" just confused the hell out of me since I'm completely new to C++ and have no idea what anything is.A word of advice, then -- RTFM. Read everything, in fact, because right on the Code::Blocks download page it says:
NOTE: The codeblocks-8.02mingw-setup.exe file includes the GCC compiler and GDB debugger from MinGW.
I am having the same issue but I downloaded from the codeblocks-8.02mingw-setup.exe and have double-checked all of my settings but cannot find any reason why iostream cannot be found. Any help?
I have tried that and it didn't work. :(
I am having the same problem with "iostream" and I moved my "test.c" to C:/Program Files/codeblocks and it worked.
Two questions:
1. Why?
2. What do I have to do to compile *.c in other directories
Global Settings:
GNU GCC Complier
Toolchain ex
instal dir = C:\Program Files\CodeBlocks\MinGW
no make.exe in bin directory but found a mingw32-make.exe
Windows 2000 Pro
Dell Latitudue Laptop
===================================================================
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
int main()
{
vector<string> SS;
SS.push_back("The number is 10");
SS.push_back("The number is 20");
SS.push_back("The number is 30");
cout << "Loop by index:" << endl;
int ii;
for(ii=0; ii < SS.size(); ii++)
{
cout << SS[ii] << endl;
}
cout << endl << "Constant Iterator:" << endl;
vector<string>::const_iterator cii;
for(cii=SS.begin(); cii!=SS.end(); cii++)
{
cout << *cii << endl;
}
cout << endl << "Reverse Iterator:" << endl;
vector<string>::reverse_iterator rii;
for(rii=SS.rbegin(); rii!=SS.rend(); ++rii)
{
cout << *rii << endl;
}
cout << endl << "Sample Output:" << endl;
cout << SS.size() << endl;
cout << SS[2] << endl;
swap(SS[0], SS[2]);
cout << SS[2] << endl;
int i;
scanf("%d", &i);
return 0;
}
mingw32-g++.exe -IC:\LIBS\SDL-1.2.14\include -c "C:\Documents and Settings\User\Desktop\test.cpp" -o "C:\Documents and Settings\User\Desktop\test.o"
C:/Documents and Settings/User/Desktop/test.cpp:1:20: iostream: No such file or directory
C:/Documents and Settings/User/Desktop/test.cpp:2:18: vector: No such file or directory
C:/Documents and Settings/User/Desktop/test.cpp:3:18: string: No such file or directory
C:/Documents and Settings/User/Desktop/test.cpp: In function `int main()':
C:/Documents and Settings/User/Desktop/test.cpp:10: `vector' undeclared
(first use this function)
C:/Documents and Settings/User/Desktop/test.cpp:10: (Each undeclared
identifier is reported only once for each function it appears in.)
C:/Documents and Settings/User/Desktop/test.cpp:10: `string' undeclared
(first use this function)
C:/Documents and Settings/User/Desktop/test.cpp:10: `SS' undeclared (first
use this function)
C:/Documents and Settings/User/Desktop/test.cpp:16: `cout' undeclared (first
use this function)
C:/Documents and Settings/User/Desktop/test.cpp:16: `endl' undeclared (first
use this function)
C:/Documents and Settings/User/Desktop/test.cpp:26: `::const_iterator'
undeclared (first use here)
C:/Documents and Settings/User/Desktop/test.cpp:26: parse error before `;'
token
C:/Documents and Settings/User/Desktop/test.cpp:27: `cii' undeclared (first
use this function)
C:/Documents and Settings/User/Desktop/test.cpp:34: `::reverse_iterator'
undeclared (first use here)
C:/Documents and Settings/User/Desktop/test.cpp:34: parse error before `;'
token
C:/Documents and Settings/User/Desktop/test.cpp:35: `rii' undeclared (first
use this function)
C:/Documents and Settings/User/Desktop/test.cpp:45: `swap' undeclared (first
use this function)
Process terminated with status 1 (0 minutes, 0 seconds)
16 errors, 0 warnings
reason i wasnt sure about its handling of long pathnames is if i use C:\program files <- ups space in name \codeblocks atleast msys gave me some trouble there unless i used the dos short version.Yes, I had an issue too when using GCC via msys, but so long as I used double quotes whenever refering to long directory names (e.g. cd C:/"Program Files"/CodeBlocks), it worked fine.
checked dev-cpp installation and indeed it does set the compiler path in the system PATH the uninstall feature doesnt remove it though so seems like an oversight.That's interesting, thanks a lot for checking that. I checked my PATH variable now and it's clean (no Dev-C++ leftovers), I suppose that resetting the compiler directory in CodeBlocks fixed that too.
i guess the reason why codeblocks picks it up is it checks both registry and path and maybe executable names before checking its own directory ?
ofc with so many supported compilers this can get a bit hairy especially if the user had several different compilers at some point.Yes, I suppose so. In fact, it seems that's probably the reason for my erratic compiler behavior for some time now. I've installed Dev-C++ and MSVC++ in the past, before setting up CodeBlocks. I have uninstalled both at the moment, but it seems that there are certain traces left behind in the system from them. For instance, until recently, although .cpp and .h files were set to open with CodeBlocks as the default program, their "Type" attribute was still given as "MS Visual C++ .cpp file" I think. I had to manualy remove some leftover components from MSVC via "Add or Remove Programs" for the file type to stop being affected by it.
atleast its easy to fix once known maybe a good idea to sticky it ?I wonder if others having the same problem have been using multiple compilers too. I don't know if resetting Compiler Install Directory would fix it for everyone, but if anyone's got the same issues occurring, it's probably a good thing to check.
I can not help you, all I can suggest is delete and re-install.
I would suggest un-installing Code::Blocks and deleting the config files.
How to delete configuration files.
Open using run this folder %APPDATA%\codeblocks delete at least the file default.conf; I suggest deleting them all.
Tim S.
Another thing I notice but am not sure why it occurs is that CodeBlocks somehow "remembers" it's previous settings between successively uninstalling and reinstalling it (even though it's installation folder is automatically deleted with the uninstall process). That is, CodeBlocks remembers all my added include directories and linked libraries (and also remembered the erroneous Dev-C++ directory for the compiler) between successive reinstallations, without my having to manually reinput them upon reinstalling.
Is this the place where past configurations and settings may have remained between successive reinstallations of CodeBlocks?
C:\learncpp\codeblocks\lesson\learn.c|2|error: iostream: No such file or directory|
// #include "stdafx.h" // Uncomment if Visual Studio user
#include <iostream>
int main()
{
using namespace std; // gives us access to cout and endl
int x; // declare an integer variable named x
// print the value of x to the screen (dangerous, because x is uninitialized)
cout << x << endl;
}
* name the file
I have project generated by cmake which fails to build with same message.C::B projects done with CMake are based on Makefiles. That's probably not what you want and IMHO a serious limitation of CMake. Try to convert the project top use C::B's build system instead.
Try to convert the project top use C::B's build system instead.
How can i do it?Inspect what CMake actually creates, probably turn on verbose build and then transfer the settings into C::B.
Is it possible to turn off using makefiles in code:blocks?I don't quite get the question... C::B has two build systems: A native (fast) one and a one based on Makefiles. The latter is for convenience and the latter is what CMake will create. Ask the authors of CMake for support of C::B's native build system. Surely Makefiles cannot be converted "just as is" to a native C::B project. But again: If the Makefile based build works and you don't need the special features that come with the native build system of C::B (e.g. scripting) you can leave it as it is and that would be just fine and supported by C::B, too.
Well, neither i get what you meant. cmake generated .cbp file, i opened it. Are you saying that now i can't control what directories compiler will search for headers?
hello there i am new to c++
i have tryed to compile this program but it says
#include <iostream> NO such File or Directory
was just wondering y as some of my programs work right but some do this
#include <iostream>
using namespace std
main()
{
cout << "hello there Does this program work" << endl;
cout << "check it a new line" << endl;
return(0);
}
any help would be apprecated greatly thx
C:\Users\jay\Documents\mmorpg\helloworld.cpp||In function 'int main()':|
C:\Users\jay\Documents\mmorpg\helloworld.cpp|5|error: 'cout' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings ===|
I don't understand why CodeBlocks should not set its own search paths properly when it gets installed. Hopefully the remaining problem will yield to the same approach, otherwise I'm out of ideas.
I downloaded Code::Blocks from the BerliOS site and installed it from the binary set-up file. There were no configuration questions in the install. I am running Vista, but I have also tried it on XP and gotten the same results (I will double-check this later).I don't understand why CodeBlocks should not set its own search paths properly when it gets installed. Hopefully the remaining problem will yield to the same approach, otherwise I'm out of ideas.
Code::Blocks is an IDE, not a compiler, so it don't need to set searchpaths.
Normally the compiler finds his libs and headers without explicitely setting a searchpath.
If not, something is wrong with either your setup and/or yur compiler !
I am assuming that I got the compiler along with the BerliOS download -- I did not download it separately. Am I supposed to find and install a compiler separately and configure it into the IDE in order for this to work?
I set the directory to the standalone MinGW's location, in my case C:/MinGW
However, I find that the problem is equally solved by setting it to the MinGW directory found in CodeBLocks own installation folder, and that's perhaps the preferred solution.
In my case, it would be C:\Program Files\CodeBlocks\MinGW . Once this directory is set, the header files are located without problems.
Settings > Compiler > Toolchain Executables > Compiler's Installation Directory