LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2010, 08:23 PM   #1
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Rep: Reputation: 0
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?
 
Old 11-17-2010, 03:38 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by AlegroGuy View Post
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.
 
Old 11-17-2010, 07:59 AM   #3
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 11-17-2010, 08:54 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,450

Rep: Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719
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.
 
Old 11-17-2010, 10:12 AM   #5
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 11-17-2010, 10:19 AM   #6
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 11-17-2010, 10:23 AM   #7
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 11-17-2010, 03:08 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,450

Rep: Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719
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
 
Old 11-17-2010, 03:39 PM   #9
AlegroGuy
LQ Newbie
 
Registered: Nov 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 11-17-2010, 07:17 PM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,450

Rep: Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719Reputation: 1719
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kerenel Compiled with x86_64 gcc vs. i686 gcc zvivered Linux - Embedded & Single-board computer 1 10-27-2009 09:52 AM
gcc errors while compiling my server.c program using MySQL linuxfan84 Programming 3 06-18-2008 02:26 AM
Having trouble debugging a program. Uses gtk, cairo, and allegro. Winter Knight Programming 1 07-26-2007 01:46 AM
Successfully Compiled Program has Symbol Lookup Errors Kenji Miyamoto Programming 2 02-07-2006 02:32 PM
executing program compiled gcc purusingh Programming 1 08-25-2003 01:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration