Code::Blocks

User forums => Help => Topic started by: shiguy48 on November 02, 2007, 03:19:03 pm

Title: #include <iostream> NO such File or Directory
Post by: shiguy48 on November 02, 2007, 03:19:03 pm
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
Title: Re: #include <iostream> NO such File or Directory
Post by: TDragon on November 02, 2007, 03:32:01 pm
Sounds like your compiler is incorrectly installed; are you using MinGW/GCC?

(Note: Once this problem is fixed, you'll also need a semicolon ";" after using namespace std and an "int" before main(), to successfully compile.)
Title: Re: #include <iostream> NO such File or Directory
Post by: killerbot on November 02, 2007, 04:01:31 pm
just checked this with MinGW GCC4.2.1, works ok, with the side effect that the the file is found twice !!!
Once in : c:\MinGW\lib\gcc\mingw32\4.2.1-dw2\include\c++\iostream
and once in  C:\MinGW\lib\gcc\mingw32\4.2.1-dw2\include\c++\iostream

note the difference : c <---> C:

This is something we didn't have with MinGW GCC 3.4.5, or it should be a very recent regression; Can anyone check this with the latest svn on MinGW3.4.5 ? The earliest I can get hold of a MinGW GCC 3.4.5 system is on monday.
Title: Re: #include <iostream> NO such File or Directory
Post by: gd_on on November 02, 2007, 04:37:36 pm
I tried this program with gcc 3.4.5 after corrections suggested by Tdragon. (C::B 4564, windows XP, SP2)
Activating all warning and strict iso checking... full message display...
But all is working well, no problem at compilation or link time. No double definition. But may be I forgot to activate something !

gd_on
Title: Re: #include <iostream> NO such File or Directory
Post by: killerbot on November 02, 2007, 04:44:47 pm
forgot the power of remote desktop : on on GCC 3.4.5 system this is OK. So it seems that with GCC 4.2.1 we probably shouldn't add it's internal compiler list (cc plug-in), or something like that ....
Title: Re: #include <iostream> NO such File or Directory
Post by: shiguy48 on November 02, 2007, 04:49:57 pm
yes i am using ming could somebody tell step by step lol what to do im lost when it comes to all this

a wierd thing is it did for a few programs but doesnt work no so if someone can help me i will be
very apprective

thx
Title: Re: #include <iostream> NO such File or Directory
Post by: shiguy48 on November 03, 2007, 07:05:23 pm
i tryed reinstalling it but i didnt seem to work any more ideas peeps

any more help would be extremely helpful
Title: Re: #include <iostream> NO such File or Directory
Post by: Zantetsken on November 01, 2009, 07:16:12 am
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.
Title: Re: #include <iostream> NO such File or Directory
Post by: stahta01 on November 01, 2009, 05:46:59 pm
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.

FYI:

C++ files are required to have the extension .cpp when using Code::Blocks.

Tim S.
Title: Re: #include <iostream> NO such File or Directory
Post by: TDragon on November 03, 2009, 03:50:47 pm
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:

Quote
NOTE: The codeblocks-8.02mingw-setup.exe file includes the GCC compiler and GDB debugger from MinGW.

That makes it fairly clear.
Title: Re: #include <iostream> NO such File or Directory
Post by: Cplusser1 on January 06, 2010, 12:04:10 am
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?
Title: Re: #include <iostream> NO such File or Directory
Post by: stahta01 on January 06, 2010, 03:24:45 am
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?

Turn on full compiler logging
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S.
Title: Re: #include <iostream> NO such File or Directory
Post by: Cplusser1 on January 06, 2010, 07:20:55 pm
I have tried that and it didn't work. :(
Title: Re: #include <iostream> NO such File or Directory
Post by: Seronis on January 08, 2010, 04:12:50 am
I have tried that and it didn't work. :(

The 'work' part is when you take the time to copy the full log and paste it here so the experts can see what you did wrong.
Title: Re: #include <iostream> NO such File or Directory
Post by: bezerker999 on January 09, 2010, 06:00:33 am
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
===================================================================
Title: Re: #include <iostream> NO such File or Directory
Post by: stahta01 on January 09, 2010, 10:30:09 am
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
===================================================================

No idea; but  "iostream" does NOT exist in the C Language. So, you should have to change the extension to *.cpp for it to work right by default with Code::Blocks.

Tim S.
Title: Re: #include <iostream> NO such File or Directory
Post by: Cplusser1 on January 11, 2010, 10:49:51 pm
I was using a different code but as it is I have copied and pasted the code above and it still says that iostream has no such file or directory and I installed the version with the compiler included.(i made the necessary changes to the code though.)
Title: Re: #include <iostream> NO such File or Directory
Post by: Okaya on April 07, 2010, 11:22:22 pm
Hello everyone,

I too have this compilation problem with certain libraries, and not just <iostream>. I gather that my compiler is incorrectly installed, although I am unsure what is causing the problem.

I am using Code::Blocks 8.02 (MinGW version) under Windows XP, SP2. CodeBlocks seems to not find libraries included in the STL library collection. This is my test code:

Code: [Select]
#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;

}

This is my full command line build log:

Code: [Select]
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
 

So, apparently, CodeBlocks cannot find not only <iostream>, but also <vector> and <string>. I have tried uninstalling and reinstalling CodeBlocks but it does not seem to improve anything. I have also compiled this code on my system using MingW and MSYS, with the command g++ test.cpp.

Reading the previous replies in this topic, I'd suppose that if I tried compiling my source code in the CodeBlocks' installation directory, everything would work fine. But I'm trying to figure out what is causing the problem here.

Any help, feedback, or suggestions are most appreciated. Thank you in advance for any replies.

Okaya
Title: Re: #include <iostream> NO such File or Directory
Post by: reckless on April 08, 2010, 12:23:35 am
hmm strange  :?

i use codeblocks every day allbeit with my own fork of gcc/g++ and got no problems whatsoever.

however my codeblocks is installed in the root of c: so a guess would be that the paths somehow get screwed up (not sure about gcc's handling of windows long names).

could you try installing it to C:\codeblocks and see if that fixes it ?
Title: Re: #include <iostream> NO such File or Directory
Post by: Okaya on April 08, 2010, 04:57:27 pm
Thank you for your reply reckless, much appreciated.

No, installing CodeBlocks in the C:/Codeblocks directory didn't improve the situation. But, fortunately, I think I've finally managed to pinpoint the problem. It apparently has to do with the compiler's installation directory, in my case at least. Going to Settings -> Compiler and Debugger -> Toolchain Executables (Tab) , there's a section entitled "Compiler's Installation Directory".

Now, quite long ago, I had Dev-C++ installed on this machine, but have uninstalled it since, and was using MinGW and MSYS (and now CodeBlocks). However, the Compiler's Installation Directory for CodeBlocks was for some reason set to C:\Dev-Cpp  , which was the installation directory for Dev-C++ when it was installed (and apparently did not get automatically deleted even after my uninstalling it). So, apparently, all this time CodeBlocks had been using the MinGW version found in the uninstalled Dev-C++ directory, which unsurprisingly was incomplete, and thus I was missing header files during compilation. No wonder it was behaving strangely!

So, I just set the Compiler's Installation Directory to a working version of MinGW, and the code now compiles without problems. Because my standalone MinGW version is slightly more recent than the one that came with CodeBlocks, 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.


Something interesting though is that CodeBlocks somehow "inherited" this erroneous setting, because this is the first time I notice it (and I certainly didn't set it myself). How can this occur? Could it have something to do with my system's PATH variable?

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.

So, a question would be: Why does this happen, and from where does CodeBlocks reload those past settings after it has been reinstalled?


Anyway, I think that the reason why others have reported that source files compile if placed in the CodeBlocks installation directory but not outside of it probably shows that the issue is related with the Compiler Installation Directory. So I'd propose that anyone having similar problems check that this setting actually points to their compiler's directory.


Regarding GCC's support of Windows long names:

I'm not sure about this, although I've used GCC/G++ both through the MSYS command line and through an IDE, and it seems to handle long windows names fine and compile without problems. I have heard it said sometimes that it's a good idea to not include spaces in the install and project directories used, but I haven't come across any issues so far.


Okaya
Title: Re: #include <iostream> NO such File or Directory
Post by: reckless on April 08, 2010, 07:00:04 pm
aye that makes sense codeblocks seems to pickup compiler path if its set in environment variables i can confirm that.

atleast its easy to fix once known maybe a good idea to sticky it ?

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.

happy you got it fixed though :)
Title: Re: #include <iostream> NO such File or Directory
Post by: reckless on April 08, 2010, 07:41:34 pm
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.

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.

for instance i once used open watcom while having msvc installed also and every time i tried to build something it failed miserably to my horror i found out that watcom picked up the msvc compilers paths before its own and msvc had no idea of the watcom directory structure hence it failed every time cause the headers and libraries were not where it expected.

i since ditched msvc completly and just use the windows sdk's with mingw/codeblocks.

Title: Re: #include <iostream> NO such File or Directory
Post by: Okaya on April 08, 2010, 08:23:58 pm
Quote from: reckless
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.

Quote from: reckless
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.

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

Quote from: reckless
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.

Quote from: reckless
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.

Okaya
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on April 08, 2010, 09:12:16 pm
Older versions of C::B (including the 8.02 release) use the path and check whether the configured path is included. If another MinGW installation comes earlier in path this one is used.
Newer version (nightlies) always put the configured compiler-directory at the top of the path.

Of course this will also be included in the coming release.
Title: Re: #include <iostream> NO such File or Directory
Post by: Okaya on April 08, 2010, 10:29:05 pm
That's very helpful jens, thank you for this clarification.

Okaya
Title: Re: #include <iostream> NO such File or Directory
Post by: Okaya on April 08, 2010, 10:43:07 pm
I just found a post in this forum, referring a member having build problems to uninstalling CodeBlocks and deleting the configuration files in the C:\Documents and Settings\User\Application Data\codeblocks directory.

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.



Is this the place where past configurations and settings may have remained between successive reinstallations of CodeBlocks? I wrote a while ago:

Quote from: Okaya
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.

Okaya

Title: Re: #include <iostream> NO such File or Directory
Post by: jens on April 08, 2010, 10:57:45 pm
Is this the place where past configurations and settings may have remained between successive reinstallations of CodeBlocks?

Yes !
Title: Re: #include <iostream> NO such File or Directory
Post by: reckless on April 09, 2010, 07:51:02 am
good to know thanks jens :)



Title: Re: #include <iostream> NO such File or Directory
Post by: monsto on June 04, 2010, 10:28:23 pm
first of all, to the regular users of this forum: this issue is not a lollable pebkac or ID-10t error. it is a legitimate issue. i followed Okaya's advices with the Toolchain executables tab (compilers installation dir is C:\Program Files\CodeBlocks\MinGW) and checking the windows path statement for Dev-C++ baggage, and everything is copacetic.

the problem:
after default installation, diving right in with example code returns errors collateral to the first.
Code: [Select]
C:\learncpp\codeblocks\lesson\learn.c|2|error: iostream: No such file or directory|
the reproduction:
* install codeblocks.
* start it up and click "create a new project."
* * accept the wizard defaults
* Rclick Management panel > Projects tab > [proj name] > Sources > main.cpp
* choose build file.

the log shows no errors.

* click new file
* choose Empty File
* "yes" to active project
* name the file
* ok to multiple selection
* paste some newbie trying to get started with learning the program code. (pasted from learncpp.com which recommends this ide)
Code: [Select]
// #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;
}
* rclick the file in the sources folder of the management sidebar.
* choose build file.
* note the pile of errors starting with the title of this thread.

i've done nothing additional to my install of the program before coming across this problem. obviously some kind of path problem. however, the paths i have in relevant locations is correct.

the request:
to be able to add a file on default install and compile it without errors.

if i need to change a path somewhere, great.
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on June 04, 2010, 10:54:38 pm
* name the file

Which name do you give the file ?
Title: Re: #include <iostream> NO such File or Directory
Post by: monsto on June 04, 2010, 11:12:29 pm
anything. i started by trying to make it something relevant to what i was doing (lesson, learn1, learncpp, etc) but eventually i gave up and settled for the suggested Untitled12
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on June 04, 2010, 11:27:04 pm
The ending has to be cpp or cxx, to make the compiler detect it as c++-file.
Title: Re: #include <iostream> NO such File or Directory
Post by: monsto on June 04, 2010, 11:34:06 pm
great. thanks.

1) in the scenario above, how would that be accomplished? do i need to choose a different new file type or just rename the file?

2) how would a person new to c++ find how to have the ide run as what tutorials expect to be default behaviour?

Title: Re: #include <iostream> NO such File or Directory
Post by: jens on June 04, 2010, 11:41:27 pm
You can rename it, but you might have to close and reopen the project.

If you are new to c++, you should buy you a good book or find a good online-tutorial or forum.

This forum is not dedicated to teaching beginners how to program or how to use a compiler.

Without basic knowledge you will have problems with almost every IDE.
Title: Re: #include <iostream> NO such File or Directory
Post by: monsto on June 04, 2010, 11:53:20 pm
i have done that.

the tutorials on learncpp.com nor the examples in sams "c++ in 24hrs" had expectation issues with the other couple of ide's i tried after encountering this... Dev-C++ for example.

it's not my lack of c++ knowledge that is at issue, it's the expected default behaiviour of codeblocks. It is unexpected that i'd need to rename a file during the "open new file" process.
Title: Re: #include <iostream> NO such File or Directory
Post by: monsto on June 05, 2010, 01:07:14 am
after jackin around with it for a while, here's the solution for the problem in the OP for codeblocks 10.05


You should now have a file in which you can paste source from a tutorial and it should compile as expected.
Title: Re: #include <iostream> NO such File or Directory
Post by: Leron on August 23, 2010, 01:24:05 am
Similar problem here. I have project generated by cmake which fails to build with same message. Codeblocks sees the file and i can include it in other projects. I unchecked "this is custom makefile" in the generated project properties but no effect. I am using TDM-GCC 32 on XP x64, CB 10.05
Title: Re: #include <iostream> NO such File or Directory
Post by: MortenMacFly on August 23, 2010, 06:58:52 am
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.
Title: Re: #include <iostream> NO such File or Directory
Post by: Leron on August 23, 2010, 08:29:05 pm
Quote
Try to convert the project top use C::B's build system instead.

How can i do it? Is it possible to turn off using makefiles in code:blocks?
Title: Re: #include <iostream> NO such File or Directory
Post by: MortenMacFly on August 23, 2010, 08:37:53 pm
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.

So neither there is a "turning off" in C::B, nor this is a limitation of C::B.
Title: Re: #include <iostream> NO such File or Directory
Post by: Leron on August 25, 2010, 10:05:12 pm
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?
Title: Re: #include <iostream> NO such File or Directory
Post by: stahta01 on August 26, 2010, 01:15:22 am
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?

No, we are saying you need to learn to use the Makefile system to do that fix.

Or, convert your program to use the Code::Blocks native build system; this may be simple to very hard to do, Depending on the complexity and size of your application/library.

Note: I suggest reading what options can be passed to make command using the makefile to solve this problem and after finding the options; ask where in Code::Blocks the make options can be placed.

Edit: What I personally would do would be to create an new makefile that uses the CMake generated top makefile and inside my new makefile I would do all the changes needed to fix problems like you are having. But, this requires knowing how to write simple to moderately complex makefiles.  I would then change C::B to use my new makefile.

Tim S.


Title: Re: #include <iostream> NO such File or Directory
Post by: Leron on August 26, 2010, 04:08:47 pm
Well, cmake is able to generate VC++ projects, i guess on windows that would be fine.
Title: Re: #include <iostream> NO such File or Directory
Post by: jayushkin on September 22, 2010, 11:03:14 am
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

I had the same problem.  I managed to fix the file not found problem by adding CodeBlocks/MinGW/lib/gcc/mingw32/4.4.1/include/c++ but I am still getting "cout" not resolved.

Quote
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.
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on September 22, 2010, 11:19:18 am
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 !
Title: Re: #include <iostream> NO such File or Directory
Post by: jayushkin on September 22, 2010, 11:51:19 am
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 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).

Now there are searchpaths that can be set in the IDE (there are several windows for inputting them) -- who uses these?  The compiler or the IDE?  Somebody else?

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?
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on September 22, 2010, 12:16:46 pm
The search-paths are normally used for additional libraries/sdk's.
On my windows-system(s) I never had problems with using MinGW standard-headers.
And I never have to add anything into the search-directories for a simple "Hello world"-program that does not use third-party libs/sdk's.
Title: Re: #include <iostream> NO such File or Directory
Post by: stahta01 on September 22, 2010, 05:43:19 pm
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?

If the download file has "mingw" in the name you got the Windows MinGW GCC with it.

Note: If you already had MinGW GCC installed, Code::Blocks may have use the prior version instead.

Note2: Some people claim that Code::Blocks does NOT always configure the Compiler ToolChain correctly. Link on Wiki about Compiler Toolchain http://wiki.codeblocks.org/index.php?title=Installing_a_supported_compiler#Compiler-neutral_setup_steps

Note3: If you have a version of MinGW in the location "x:\MinGW" for any drive X; example "C:\MinGW" then a second install of MinGW GCC will NOT work right.

Note4: You should never use the file extension ".c" when you want the file compiled as an "C++" file.

Note5: If you have Cygwin install, it should NOT be in the path for certain cases when using MinGW GCC. IIRC, the compiling of wxWidgets, using MinGW GCC is one of those cases.

Tim S.

Title: Re: #include <iostream> NO such File or Directory
Post by: heello123 on April 03, 2011, 10:01:56 pm
hi see i had the same problem i have gcc compiler and i have it in the right directory and compiler and i have compilerlogging on and when i go to make a new file i make it understand that ii want a c/C++ gile but for some reason it always gives me a .c file and the C++ can never be put unless i have to make a new project which contains the main.cpp fiel and if i create a new file that file won't run either and i'm using the newest code::blocks binary release and these are my run time errors:


E:\Paarth\C++ source files\Practicer\Untitled1.c|1|error: iostream: No such file or directory|
E:\Paarth\C++ source files\Practicer\Untitled1.c|2|error: cmath: No such file or directory|
E:\Paarth\C++ source files\Practicer\Untitled1.c|3|warning: parameter names (without types) in function declaration|
E:\Paarth\C++ source files\Practicer\Untitled1.c|4|error: expected identifier or '(' before '{' token|
E:\Paarth\C++ source files\Practicer\Untitled1.c||In function 'main':|
E:\Paarth\C++ source files\Practicer\Untitled1.c|13|error: 'using' undeclared (first use in this function)|
E:\Paarth\C++ source files\Practicer\Untitled1.c|13|error: (Each undeclared identifier is reported only once|
E:\Paarth\C++ source files\Practicer\Untitled1.c|13|error: for each function it appears in.)|
E:\Paarth\C++ source files\Practicer\Untitled1.c|13|error: expected ';' before 'namespace'|
E:\Paarth\C++ source files\Practicer\Untitled1.c|14|error: 'cout' undeclared (first use in this function)|
E:\Paarth\C++ source files\Practicer\Untitled1.c|14|error: 'endl' undeclared (first use in this function)|
E:\Paarth\C++ source files\Practicer\Untitled1.c|16|error: 'cin' undeclared (first use in this function)|
E:\Paarth\C++ source files\Practicer\Untitled1.c|19|error: 'check' undeclared (first use in this function)|
||=== Build finished: 11 errors, 1 warnings ===|
Title: Re: #include <iostream> NO such File or Directory
Post by: jens on April 03, 2011, 10:34:42 pm
You have to type the correct file-ending (.cpp n your case) if you save the file, default file-ending is .c at the moment.
Title: Re: #include <iostream> NO such File or Directory
Post by: hundred4ever on April 14, 2016, 01:05:40 pm
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


Your solution worked for me. Thanks. :)

In my case I was using 16.01mingwsetup.exe, and my compiler was set to C:\MinGW and wasn't working.

Changing the compiler's installation directory to link to CodeBlocks' MinGW worked for me.
I changed it to -- C:\Program Files (x86)\CodeBlocks\MinGW