Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Code::Blocks can't find iostream

Credits go to BAF, Dario ff, Neil Walker, Slartibartfast, and Vanneto for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
Code::Blocks can't find iostream
Neil Black
Member #7,867
October 2006
avatar

I just downloaded and installed Code::Blocks onto my laptop, intending to finally get back into Allegro and C++ now that the semester is over. I made a short little Hello World program to test it:

#include <iostream>
int main()
{
    std::cout << "Text";
    return 0;
}

But when I try to compile it, it tells me that iostream doesn't exist! I've reinstalled Code::Blocks and tried installing Mingw separately, but I haven't been able to fix the problem.

Neil Walker
Member #210
April 2000
avatar

do any other include files work (C and C++), e.g. <stdio.h> and <string>

Sounds like you haven't configured code blocks with mingw properly.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Dario ff
Member #10,065
August 2008
avatar

^ Sounds like that to me too. I'd suggest looking at the path of the compiler in Code::Blocks, and if you still can't find it, run a search for iostream on your whole disk.

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Neil Black
Member #7,867
October 2006
avatar

It finds <stdio.h>.

When I search for iostream, the only things that are turned up are a few old source files I have lying around.

BAF
Member #2,981
December 2002
avatar

Does the atrocious mingw installer still make you check a box for libstdc++? Without that, you don't have iostream, etc.

Vanneto
Member #8,643
May 2007

Are you sure you named your file *.cpp? Did you install g++?

In capitalist America bank robs you.

Neil Black
Member #7,867
October 2006
avatar

I reinstalled mingw and checked all the options available, but it didn't fix the problem.

BAF
Member #2,981
December 2002
avatar

File doesn't have to be named .cpp, it just has to be compiled with g++. You can name it whatever you want for the most part.

Neil Walker
Member #210
April 2000
avatar

When you downloaded mingw separately did you include c++, you may have just downloaded C. I can't remember the install process so this could be me talking rubbish.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Slartibartfast
Member #8,789
June 2007
avatar

1) Download and install the C::B version the comes with the compiler, it is around 20 megabytes instead of the 10 megabytes the "regular" version.
2) Create the project as a console project and select C++ when it asks.

If you did both, then I have no further advice at the moment.

Neil Black
Member #7,867
October 2006
avatar

2)Create the project as a console project and select C++ when it asks.

That did it.

You'd think that you could just make a quick test program without starting a whole new project... :-/

GClaudiu
Member #10,728
February 2009
avatar

Just to make sure, go to Settings - Compiler and debugger - Toolchain executables and Auto-detect. It should pop a window saying it found GCC. Click ok and if it still isn't working I really can't help you... (maybe you also have to restart C::B, I'm not sure)

Neil Black
Member #7,867
October 2006
avatar

My only concern now is getting Allegro installed with Code::blocks. I'm off to see the wiki, the wonderful wiki of Allegro!

LennyLen
Member #5,313
December 2004
avatar

My only concern now is getting Allegro installed with Code::blocks. I'm off to see the wiki, the wonderful wiki of Allegro!

Unless you really feel the need to compile Allegro yourself, installing it is as simple as downloading the binary package and extracting the contents to your MinGW directory.

Compiling it yourself isn't particularly difficult either. Just extract the source to a directory, bring up a command prompt and navigate to the directory you extracted the source to and type the following:

fix mingw
mingw32-make
mingw32-make install

If you want the debug version of the lirary as well, then also type:

mingw32-make DEBUGMODE=1
mingw32-make install DEBUGMODE=1

Neil Black
Member #7,867
October 2006
avatar

Ok, I installed Allegro just like LennyLen said (extracted the binary into my Mingw directory). I went into the linker options on Code::Blocks and linked to the library (if I'm recalling correctly from way back when I used Dev-Cpp, I link to liballeg.a), but it says there is no such file as allegro.h, and that none of the functions have been defined.

:(

LennyLen
Member #5,313
December 2004
avatar

Have you checked yourself whether or not allegro.h is in the MinGW\include directory?

Neil Black
Member #7,867
October 2006
avatar

Do I need to put the entire include folder from the Allegro directory into the Mingw directory, or just the allegro.h file?

LennyLen
Member #5,313
December 2004
avatar

Yes, everything. allegro.h includes a whole lot of other header files as well.

Neil Black
Member #7,867
October 2006
avatar

One final question: is there somewhere I can put the allegro dll so that all the allegro programs on my computer can run? I compiled and ran a test program, and it shouted at me about not having the dll. I know I had it set up on my old computer, but I don't remember how.

Matthew Leverton
Supreme Loser
January 1999
avatar

echo %PATH%

Anywhere in there.

Neil Black
Member #7,867
October 2006
avatar

Do what now?

Remember, besides sitting down and typing actual code, I don't know a whole lot about computers.

Trent Gamblin
Member #261
April 2000
avatar

Open a command prompt and type what Matthew said. Put it in any of the directories that is printed out (they're separated by ; ).

Neil Black
Member #7,867
October 2006
avatar

Huzzah! Success! Thanks all.

One absolute final question, for reals this time.

Where can I download the allegro docs? I remember having a really nice offline html copy of them, but it doesn't seem to have been included when I installed Allegro.

Trent Gamblin
Member #261
April 2000
avatar

They're included with the source code releases, in the docs directory.

Neil Black
Member #7,867
October 2006
avatar

The only file under html in the docs directory it something called tmpfile.

 1   2 


Go to: