LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Errors in Allegro in a C++ program, compiled with gcc, in a Linux console (https://www.linuxquestions.org/questions/programming-9/errors-in-allegro-in-a-c-program-compiled-with-gcc-in-a-linux-console-844724/)

AlegroGuy 11-16-2010 08:23 PM

Errors in Allegro in a C++ program, compiled with gcc, in a Linux console
 
Hi, I just setup something called Allegro (Atari Low Level Game Routines) (I first downloaded it directly into my Linux console (SSH) directly, with lynx, and then I unzipped it from a tar.gz, and then followed the instructions in the README.txt file and READMEmake.txt file to set it up, and then tried a sample C++ program to see if it would work. And there is nothing wrong with my program (it does essentially nothing, but test to see if it can successfully include the allegro files), but there are tons of problems with the files in Allegro being included, here are just some of the errors:

allegro5/bitmap.h:154: error: 'al_unmap_rgb' has not been declared
allegro5/bitmap.h:154: error: expected identifier before '(' token
allegro5/bitmap.h:154: error: expected `)' before 'color'
allegro5/bitmap.h:154: error: expected ',' or '...' before 'color'
allegro5/bitmap.h:154: error: expected constructor, destructor, or type conversion before ')' token
allegro5/bitmap.h:155: error: 'al_unmap_rgba' has not been declared
allegro5/bitmap.h:155: error: expected identifier before '(' token
allegro5/bitmap.h:155: error: expected `)' before 'color'
allegro5/bitmap.h:155: error: expected ',' or '...' before 'color'
allegro5/bitmap.h:155: error: expected constructor, destructor, or type conversion before ')' token
allegro5/bitmap.h:156: error: 'al_unmap_rgb_f' has not been declared
allegro5/bitmap.h:156: error: expected identifier before '(' token
allegro5/bitmap.h:156: error: expected `)' before 'color'
allegro5/bitmap.h:156: error: expected ',' or '...' before 'color'
allegro5/bitmap.h:156: error: expected constructor, destructor, or type conversion before ')' token
allegro5/bitmap.h:157: error: 'al_unmap_rgba_f' has not been declared
allegro5/bitmap.h:157: error: expected identifier before '(' token
allegro5/bitmap.h:157: error: expected `)' before 'color'
allegro5/bitmap.h:157: error: expected ',' or '...' before 'color'
allegro5/bitmap.h:157: error: expected constructor, destructor, or type conversion before ')' token
allegro5/bitmap.h:158: error: 'al_get_pixel_format_bits' has not been declared
allegro5/bitmap.h:158: error: expected identifier before '(' token
allegro5/bitmap.h:158: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:162: error: 'al_convert_mask_to_alpha' has not been declared
allegro5/bitmap.h:162: error: expected identifier before '(' token
allegro5/bitmap.h:162: error: 'ALLEGRO_COLOR' has not been declared
allegro5/bitmap.h:162: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:165: error: 'al_set_clipping_rectangle' has not been declared
allegro5/bitmap.h:165: error: expected identifier before '(' token
allegro5/bitmap.h:165: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:166: error: 'al_get_clipping_rectangle' has not been declared
allegro5/bitmap.h:166: error: expected identifier before '(' token
allegro5/bitmap.h:166: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:169: error: 'al_create_sub_bitmap' has not been declared
allegro5/bitmap.h:169: error: expected identifier before '(' token
allegro5/bitmap.h:169: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:170: error: 'al_is_sub_bitmap' has not been declared
allegro5/bitmap.h:170: error: expected identifier before '(' token
allegro5/bitmap.h:170: error: expected constructor, destructor, or type conversion before ';' token
allegro5/bitmap.h:173: error: 'al_clone_bitmap' has not been declared
allegro5/bitmap.h:173: error: expected identifier before '(' token
allegro5/bitmap.h:173: error: expected constructor, destructor, or type conversion before ';' token

and my program itself is just simply:

#include "allegro5/allegro.h"

int main( ){
return 0;
}
END_OF_MAIN( );

What's going on? How do I fix this?

JohnGraham 11-17-2010 03:38 AM

Quote:

Originally Posted by AlegroGuy (Post 4161324)
here are just some of the errors:

Always always always always always go after the first error first. Always.

Please post the very first error you got, or nobody will be able to help you.

AlegroGuy 11-17-2010 07:59 AM

I was not able to see my first error no matter what I did.
 
Yeah - I tried to see my first error every way I could think of before I even posted here. There were so many errors that I could not even scroll back to my first error. I tried many things to see my first error:

1) I tried piping into a more command:
gcc a.cpp | more
2) I tried piping into a less command:
gcc a.cpp | less
3) I tried redirecting to a file:
touch o.txt
gcc a.cpp > o.txt
4) I tried redirecting standard error into a file:
gcc a.cpp 2> o.txt
5) I tried piping it into a tee and teeing it into a file:
gcc a.cpp | tee o.txt

None of those commands worked as you might expect them to. Even with using those commands it just showed all the errors directly, did NOT redirect anything, and in the case of the more and less commands, they did NOT allow me to see the errors one screen at a time.

ntubski 11-17-2010 08:54 AM

Hmm, number 4) should have worked.

If you are writing in C++ you should use g++ to compile. Also, guessing based on a few tutorials I just glanced at, you should #include <allegro.h> and add -I /whereever/allegro/is/installed/allegro5 when compiling. It's likely the allegro headers don't use the allegro5/ prefix when #including.

AlegroGuy 11-17-2010 10:12 AM

I just tried what you said, but it doesn't work yet...
 
I copied my .cpp file over to my home directory, which again looks like this:

Code:

#include <cstdio>
#include "<allegro.h>"

int main( ){
  printf "Hello World";
  return 0;
}
END_OF_MAIN( );

I also did some searching around and am now compiling the code using this command:

g++ a.cpp -o a -lalleg -I ~/allegro-5/include/allegro5 -L ~/allegro-5/Build/lib

With that, I am getting these errors (these are all of them right now):

a.cpp:2:23: error: <allegro.h>: No such file or directory
a.cpp: In function 'int main()':
a.cpp:5: error: expected `;' before string constant
a.cpp: At global scope:
a.cpp:8: error: expected constructor, destructor, or type conversion before ';' token

And even though if I run that command just above, it says <allegro.h>: No such file or directory. But if I then cd to the same location that I put after -I, and then do an ls allegro.h, allegro.h is indeed there.

(In other words, that is if I do the following from the same location that I ran the gcc command from, it shows allegro.h is there):

cd ~/allegro-5/include/allegro5
ls allegro.h

AlegroGuy 11-17-2010 10:19 AM

Oh I just noticed a mistake I made...
 
I just notice that I put quotes (" ") around <allegro.h>. Ok, I took those out now, but now I just get a long lists of errors again. The errors now are basically just:

/home/int322_103b13/allegro-5/include/allegro5/someFile:someLine: error: 'X' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/someFile:someLine: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/someFile:someLine: error: expected constructor, destructor, or type conversion before ';' token

over and over again, except each time 'X' is something different, and of course "someFile" and "someLine" are also just placeholders here that are different in different errors

AlegroGuy 11-17-2010 10:23 AM

I just realized also I forgot to put brackets around "Hello World" in printf...
 
...so I added the brackets, but I still have all those errors mentioned in my post immediately above this one.

ntubski 11-17-2010 03:08 PM

It looks like my comments about the include path are wrong for version 5. Althought you may be better off with the stable branch.

Can you try redirecting stderr and stdout to a file, we really need to see the first error:
Code:

g++ ... &> output.txt

AlegroGuy 11-17-2010 03:39 PM

Thankyou, that gcc ... &> output.txt is the first thing that actually worked to redirect it. Here is the first screen of errors:

In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:26,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/base.h:50:40: error: allegro5/internal/alconfig.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:28,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/system.h:4:29: error: allegro5/config.h: No such file or directory
/home/int322_103b13/allegro-5/include/allegro5/system.h:5:27: error: allegro5/path.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:30,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/debug.h:23:27: error: allegro5/base.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:41,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/keyboard.h:20:31: error: allegro5/keycodes.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:44,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/threads.h:19:29: error: allegro5/altime.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:46,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/display.h:4:28: error: allegro5/color.h: No such file or directory
/home/int322_103b13/allegro-5/include/allegro5/display.h:5:29: error: allegro5/bitmap.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:48,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/bitmap_io.h:5:27: error: allegro5/file.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:53,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/file.h:6:27: error: allegro5/utf8.h: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:57,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/fmaths.h:23:28: error: allegro5/fixed.h: No such file or directory
/home/int322_103b13/allegro-5/include/allegro5/fmaths.h:42:38: error: allegro5/inline/fmaths.inl: No such file or directory
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:26,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/base.h:77: error: expected constructor, destructor, or type conversion before '(' token
/home/int322_103b13/allegro-5/include/allegro5/base.h:78: error: 'al_run_main' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/base.h:78: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/base.h:78: error: expected constructor, destructor, or type conversion before ';' token
In file included from /home/int322_103b13/allegro-5/include/allegro5/allegro.h:28,
from a.cpp:2:
/home/int322_103b13/allegro-5/include/allegro5/system.h:17: error: 'al_install_system' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:17: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:17: error: expected constructor, destructor, or type conversion before ';' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:18: error: 'al_uninstall_system' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:18: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:18: error: expected constructor, destructor, or type conversion before ';' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:19: error: 'al_get_system_driver' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:19: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:19: error: expected constructor, destructor, or type conversion before ';' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:20: error: expected constructor, destructor, or type conversion before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:34: error: expected constructor, destructor, or type conversion before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:36: error: 'al_set_org_name' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:36: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:36: error: expected constructor, destructor, or type conversion before ';' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:37: error: 'al_set_app_name' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:37: error: expected identifier before '(' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:37: error: expected constructor, destructor, or type conversion before ';' token
/home/int322_103b13/allegro-5/include/allegro5/system.h:38: error: 'al_get_org_name' has not been declared
/home/int322_103b13/allegro-5/include/allegro5/system.h:38: error: expected identifier before '(' token

ntubski 11-17-2010 07:17 PM

So I think you need
Code:

-I/home/int322_103b13/allegro-5/include
and go back to #include <allegro5/allegro.h>

Ideally you would use pkg-config to get the right directories. Since it's in a non-standard location you would run something like
Code:

PKG_CONFIG_PATH=<dir> pkg-config --cflags --libs
where <dir> is the directory containing allegro-5.0.pc.


All times are GMT -5. The time now is 06:54 AM.