Hello there,
I've been running in to a ton of problems lately. I'm in Vocational school, and I use Ubuntu on my computer there. I've been programming with the allegro library, and things were going fine. Then, when I went to compile a program I was making (a Pong game), Code::Blocks told me it couldn't find <iostream> and <string>. I compiled something like 10 minutes before that, and didn't do anything.
I went home, and tried the code on my Ubuntu on my laptop and I got the same problem. So I figured it as the code, and I wrote a simple hello world program to test my iostream. It didn't work. Here're the errors I got:
Errors:Code:#include <iostream> using namespace std; int main(void){ cout << "Hello world!"; cin.get(); return 0; }
when I compile the code for the Pong game I was making (I know there are bugs, I just wanted to compile and see if it would show the paddles -- I found out there are htings I need to fix before it works, but look at everything else)Code:/usr/include/c++/4.3.3/iostream|44|error: bits/c++config.h: No such file or directory| /usr/include/c++/4.3.3/bits/stringfwd.h||In function ‘_GLIBCXX_BEGIN_NAMESPACE’:| /usr/include/c++/4.3.3/bits/stringfwd.h|48|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|51|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|54|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|58|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|60|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/stringfwd.h|68|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/lib/gcc/i486-linux-gnu/4.3.3/include/stddef.h|214|error: storage class specified for parameter ‘size_t’| /usr/lib/gcc/i486-linux-gnu/4.3.3/include/stddef.h|326|error: storage class specified for parameter ‘wchar_t’| /usr/include/c++/4.3.3/cstddef|54|error: expected declaration specifiers before ‘_GLIBCXX_BEGIN_NAMESPACE’| /usr/include/c++/4.3.3/cstddef|57|error: expected declaration specifiers before ‘using’| /usr/include/c++/4.3.3/cstddef|59|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/cwchar|70|error: expected declaration specifiers before ‘_GLIBCXX_BEGIN_NAMESPACE’| /usr/include/c++/4.3.3/cwchar|74|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/bits/postypes.h|77|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘streamsize’| /usr/include/c++/4.3.3/bits/postypes.h|90|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|186|error: expected declaration specifiers before ‘;’ token| /usr/include/c++/4.3.3/bits/postypes.h|193|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|198|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|207|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/postypes.h|209|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/postypes.h|211|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/iosfwd|54|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|57|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|60|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|63|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|66|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|70|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|74|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|78|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|82|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|85|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|88|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|91|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|94|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|97|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|102|error: expected declaration specifiers before ‘class’| /usr/include/c++/4.3.3/iosfwd|132|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|133|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|134|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|135|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|136|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|137|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|138|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|139|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|140|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|141|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|142|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|143|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/iosfwd|144|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| ||More errors follow but not being shown.| ||Edit the max errors limit in compiler options...| ||=== Build finished: 50 errors, 0 warnings ===|
Here are my errors:Code:#include <allegro.h> #include <iostream> #include <string> using namespace std; void Check_Null(BITMAP* Picture, string Type, string Error); int Get_Rand(void); int main(void){ cout << "This is a Pong game by Lorgon Jortle. Mar 31, 2009.\n"; cin.get(); allegro_init(); install_keyboard(); /**Declare variables**/ //Bitmaps BITMAP* buffer = NULL; BITMAP* player1 = NULL; BITMAP* player2 = NULL; BITMAP* ball = NULL; //Integers int player1_x, player1_y, player2_x, player2_y; int ball_x, ball_y; int ball_speed, ball_direction; //Ball direction 1 = left, 2 = left up, 3 = left down, 4 = right, 5 = right up, 6 = right down int player1_bb, player2_bb; //The line on the side of the paddle to check for collisions //Booleans bool Collision = false; /**Assign variables**/ //Integers player1_x = 0; player1_y = 240; player2_x = 640; player2_y = 240; ball_speed = 2; //Bitmaps buffer = create_bitmap(640, 480); Check_Null(buffer, "buffer". "buffer failed to load."); player1 = load_bitmap("player1.bmp", NULL); Check_Null(player1, "player1.bmp", "player1.bmp failed to load."); player2 = load_bitmap("player2.bmp", NULL); Check_Null(player2, "player2.bmp", "player2.bmp failed to load."); ball = load_bitmap("ball.bmp", NULL); Check_Null(ball, "ball.bmp", "ball.bmp", "failed to load."); while(!key[KEY_ESC]){ //Draw the ball //Accept input if(key[KEY_UP]){ player2_y += 3; } if(key[KEY_DOWN]){ player2_y -= 3; } if(key[KEY_W]){ player1_y += 3; } if(key[KEY_S]){ player1_y -= 3; } /* LEAVE ROOM FOR FURTHER KEY PRESSES */ draw_sprite(buffer, player1, player1_x, player1_y); draw_sprite(buffer, player2, player2_x, player2_y); draw_sprite(buffer, ball, ball_x, ball_y); blit(buffer, screen, 0, 0, 640, 480); clear_bitmap(buffer); } destroy_bitmap(buffer); destroy_bitmap(player1); destroy_bitmap(player2); destroy_bitmap(ball); return 0; } END_OF_MAIN(); void Check_Null(BITMAP* Picture, string Type, string Error){ if(Picture == NULL){ cout << "Error: " << Error << endl; } else if(Picture != NULL){ cout << Type << " loaded successfully.\n"; } } END_OF_FUNCTION(Check_Null);
I have uninstalled Code::Blocks, gcc, g++, and tried installing other IDE's. Now I reinstalled gcc, g++ and Code::Blocks and it's still giving me errors.Code:/usr/include/bits/stdlib.h|21|error: #error "Never include <bits/stdlib.h> directly; use <stdlib.h> instead."| /usr/include/bits/string.h|21|error: #error "Never use <bits/string.h> directly; include <string.h> instead."| /usr/include/bits/fcntl.h|21|error: #error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."| /usr/include/bits/endian.h|4|error: #error "Never use <bits/endian.h> directly; include <endian.h> instead."| /usr/include/bits/unistd.h|21|error: #error "Never include <bits/unistd.h> directly; use <unistd.h> instead."| /usr/include/allegro/file.h|43|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘file_time’| /usr/include/allegro/file.h|52|error: expected specifier-qualifier-list before ‘time_t’| /usr/include/allegro/platform/al386gcc.h||In function ‘fixadd’:| /usr/include/allegro/platform/al386gcc.h|133|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/platform/al386gcc.h|133|error: (Each undeclared identifier is reported only once| /usr/include/allegro/platform/al386gcc.h|133|error: for each function it appears in.)| /usr/include/allegro/platform/al386gcc.h||In function ‘fixsub’:| /usr/include/allegro/platform/al386gcc.h|171|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/platform/al386gcc.h||In function ‘fixmul’:| /usr/include/allegro/platform/al386gcc.h|209|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/platform/al386gcc.h||In function ‘fixdiv’:| /usr/include/allegro/platform/al386gcc.h|261|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/platform/al386gcc.h||In function ‘fixceil’:| /usr/include/allegro/platform/al386gcc.h|366|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/inline/fmaths.inl||In function ‘ftofix’:| /usr/include/allegro/inline/fmaths.inl|32|error: ‘ERANGE’ undeclared (first use in this function)| /usr/include/allegro/inline/fmaths.inl||In function ‘fixacos’:| /usr/include/allegro/inline/fmaths.inl|211|error: ‘EDOM’ undeclared (first use in this function)| /usr/include/allegro/inline/fmaths.inl||In function ‘fixasin’:| /usr/include/allegro/inline/fmaths.inl|222|error: ‘EDOM’ undeclared (first use in this function)| /usr/include/c++/4.3.3/iostream|44|error: bits/c++config.h: No such file or directory| /usr/include/c++/4.3.3/bits/stringfwd.h||In function ‘_GLIBCXX_BEGIN_NAMESPACE’:| /usr/include/c++/4.3.3/bits/stringfwd.h|48|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|51|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|54|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|58|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/stringfwd.h|60|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/stringfwd.h|68|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/cstddef|57|error: expected declaration specifiers before ‘using’| /usr/include/c++/4.3.3/cstddef|59|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/cwchar|70|error: expected declaration specifiers before ‘_GLIBCXX_BEGIN_NAMESPACE’| /usr/include/c++/4.3.3/cwchar|74|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/bits/postypes.h|77|error: storage class specified for parameter ‘streamsize’| /usr/include/c++/4.3.3/bits/postypes.h|90|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|186|error: expected declaration specifiers before ‘;’ token| /usr/include/c++/4.3.3/bits/postypes.h|193|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|198|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/bits/postypes.h|207|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/postypes.h|209|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token| /usr/include/c++/4.3.3/bits/postypes.h|211|error: expected declaration specifiers before ‘_GLIBCXX_END_NAMESPACE’| /usr/include/c++/4.3.3/iosfwd|54|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|57|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|60|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|63|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|66|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|70|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|74|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|78|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|82|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|85|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|88|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|91|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|94|error: expected declaration specifiers before ‘template’| /usr/include/c++/4.3.3/iosfwd|97|error: expected declaration specifiers before ‘template’| ||More errors follow but not being shown.| ||Edit the max errors limit in compiler options...| ||=== Build finished: 50 errors, 0 warnings ===|
Anybody have any ideas? I have the latest build-essential, and release.
Lorgon Jortle