News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

#include <iostream> NO such File or Directory

Started by shiguy48, November 02, 2007, 03:19:03 PM

Previous topic - Next topic

monsto

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

Jenna

The ending has to be cpp or cxx, to make the compiler detect it as c++-file.

monsto

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?


Jenna

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.

monsto

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

monsto

after jackin around with it for a while, here's the solution for the problem in the OP for codeblocks 10.05


  • If you've previously installed a compiler, check the windows path statement for erroneous compiler paths. (if you don't know how, use a search engine)
  • Check Settings > Compiler and debugger > Global compiler settings > Toolchain executables and verify that Compiler's installation directory is using the compiler you want it to use. if you installed MinGW with CodeBlocks, it should reflect as much. (your dirs may be diff from mine, thus no example)
  • File > New > File...
  • Choose C/C++ source
  • Choose C++
  • Name and locate your file.
  • Check Add file to active project
  • Click All
  • Click Finish

You should now have a file in which you can paste source from a tutorial and it should compile as expected.

Leron

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

MortenMacFly

Quote from: Leron on August 23, 2010, 01:24:05 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Leron

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

MortenMacFly

Quote from: Leron on August 23, 2010, 08:29:05 PM
How can i do it?
Inspect what CMake actually creates, probably turn on verbose build and then transfer the settings into C::B.

Quote from: Leron on August 23, 2010, 08:29:05 PM
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Leron

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?

stahta01

#41
Quote from: 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?

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.


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]

Leron

Well, cmake is able to generate VC++ projects, i guess on windows that would be fine.

jayushkin

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

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.

Jenna

Quote from: jayushkin on September 22, 2010, 11:03:14 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 !