|
What is the error in following little program |
toussaint1963
Member #16,622
January 2017
|
I started programming in C. int main(){ putpixel(screen, 10, 30, makecol(255, 255, 255));//macht einen Punkt readkey(); I got the error from Gcc compiler: What is wrong? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Your code is written using Allegro 4. You just installed Allegro 5. They are not compatible. I suggest using the tutorials for Allegro 5 on the wiki to get yourself started using Allegro 5. See these for more details : https://wiki.allegro.cc/index.php?title=Getting_Started#Official_Getting_Started_Guide https://wiki.allegro.cc/index.php?title=Getting_Started#Tutorials EDIT My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
The term: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
That's allegro 4 code. In allegro 5, you would call al_create_display(width,height);. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
I changed the program in allegro5: int main(){ readkey(); |
Edgar Reynaldo
Major Reynaldo
May 2007
|
On the forums, please use <code>code goes here...</code> tags to post code. It makes it much easier to read and look at. The highlighted lines (***) are incorrect : toussaint1963 said:
// Allegro 4 header #include <allegro.h> *** // incorrect allegro 5 include #include <allegro5.h> *** // incorrect allegro 5 include #include <allegro_primitives.h> *** // correct #include <allegro5/allegro_color.h> // What is this for? #include <base.h> ***
Since all allegro 5 headers live in the allegro5 include directory, you need to preface every allegro 5 header include with allegro5/ like so : #include "allegro5/allegro.h" #include "allegro5/allegro_primitives.h" #include "allegro5/allegro_color.h" Note that I used "" and not <>. That means they are user headers, and not system headers. If you use <> it will only search system header directories and not user specified ones. Also, you're using al_color_name incorrectly. If you look at the documentation, you'll see that al_color_name returns an ALLEGRO_COLOR object. You pass that to your drawing functions, like so : al_draw_line(0 , 0 , 640 , 480 , al_color_name("white") , 1); //Linie See al_color_name_to_rgb for details on which color names you can specify. Quote: set_color_depth(int) and readkey() are allegro 4 functions. You generally don't need to change the color depth. Just let allegro 5 set it for you. It will usually use 32 or 24 bit color depending on the desktop color depth. The equivalent code for readkey() in allegro 5 would be : ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue(); al_register_event_source(queue , al_get_keyboard_event_source()); do { ALLEGRO_EVENT ev; al_wait_for_event(queue , &ev); } while (ev.type != ALLEGRO_EVENT_KEY_DOWN); Try and stop mixing allegro 4 and 5 functions together. They are not compatible. The manual for Allegro 5 is here : My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
I got the error: I don't know, what the programming means. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Oh, sorry. That should have been this : ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue(); al_register_event_source(queue , al_get_keyboard_event_source()); ALLEGRO_EVENT ev; do { al_wait_for_event(queue , &ev); } while (ev.type != ALLEGRO_EVENT_KEY_DOWN);
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
I got following error messages: What is wrong? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You have to link to allegro using pkg-config or else directly to the allegro libraries. -lallegro_main -lallegro_primitives -l... My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
Haw have I to use pkg-config. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You have to set the include search directory with -I and then specify your source files and after that you have to link using pkg-config. Note the backticks around the pkg-config call. gcc -Wall -g -o main.exe -I usr/local/include main.c `pkg-config --libs allegro-5.0 allegro-primitives-5.0`
Run this command to see the different libraries for allegro : My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
I got following error message: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
toussaint1963 said:
Perhaps you should add the directory containing `allegro-5.0.pc' This indicates pkg-config doesn't know where to find the allegro-5.0.pc file. CMake may not have detected pkg-config properly when you installed allegro 5. Was pkg-config installed before you compiled Allegro? Did you try this? Edgar Reynaldo said: pkg-config --list-all | grep allegro It will tell you all the .pc files that contain allegro in their name. You may need to re-run cmake after deleting CMakeCache.txt to properly detect pkg-config. Otherwise, you need to find the directory containing allegro-5.0.pc and then add that directory to the PKG_CONFIG_PATH environment variable. Someone else will have to tell you how to do that. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
How can I set allegro-5.pc to the PKG_CONFIG_PATH? allegro-5.pc ist in the /bin/allegro-5.2.2.0/build/lib/pkgconfig directory. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
export OLD_PKG_CONFIG_PATH=$PKG_CONFIG_PATH export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/bin/allegro-5.2.2.0/build/lib/pkgconfig However, you may have installed allegro incorrectly, as that should have already been done I think... My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
bamccaig
Member #7,536
July 2006
|
That's a rather strange path... This looks more like the source tree than the installation path to me... Perhaps he didn't install... The usual incantation is something like: git clone https://domain/path/to/repo ~/src/allegro5 cd ~/src/allegro5 mkdir build cd build cmake .. make sudo make install
-- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
toussaint1963
Member #16,622
January 2017
|
I said it false |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Is that the directory you built allegro in? You need to 'make install' allegro and then pkg-config should be able to find its entries for allegro. To do that, you have to have pkg-config installed before you run cmake. You may need to rebuild allegro and rerun cmake after deleting CMakeCache.txt. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
I habe installed pkg-config zhen made cmake .., make and make install and it runs. 1#include "allegro5/allegro.h"
2#include "allegro5/allegro_primitives.h"
3#include "allegro5/allegro_color.h"
4
5
6int main(){
7
8 int w=640;
9 int h=480;
10 al_init();
11 al_install_keyboard();
12 al_create_display(w,h);
13
14
15
16
17
18 al_draw_line(0, 0, 640, 480, al_color_name("white"),2); //Linie
19 al_draw_triangle( 0, 400, 0, 450, 100, 450, al_color_name("white"),2);//gefülltes Dreieck
20 al_draw_rectangle(100, 200, 200, 250,al_color_name("white"),2);//leeres Viereck
21 al_draw_filled_rectangle( 125, 210, 175, 240, al_color_name("red"));//gefülltes Viereck
22 al_draw_circle( 500, 400, 50,al_color_name("white"),2); //leerer Kreis
23 al_draw_filled_circle(500, 400, 25,al_color_name("white"));//gefüllter Kreis
24
25 ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
26al_register_event_source(queue , al_get_keyboard_event_source());
27
28ALLEGRO_EVENT ev;
29do {
30 al_wait_for_event(queue , &ev);
31} while (ev.type != ALLEGRO_EVENT_KEY_DOWN);
32
33 return 0;
34}
Sincerely Johannes Fangmeyer |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Allegro 5's output is buffered. You have to call al_flip_display to show what you've drawn since the last call to al_flip_display. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
toussaint1963
Member #16,622
January 2017
|
Thank You. Now it runs! |
bamccaig
Member #7,536
July 2006
|
The cookies are a lie. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|