|
A strange error everytime my proggy ends... |
washuu_de
Member #16,656
March 2017
|
I'm a newbie to Allegro 5.2.2.1 and started with this source: 1#include <allegro5/allegro5.h>
2#include <allegro5/allegro_font.h>
3#include <allegro5/allegro_ttf.h>
4#include <allegro5/allegro_image.h>
5#include <allegro5/allegro_primitives.h>
6#include <allegro5/allegro_native_dialog.h>
7#include <stdio.h>
8//#include <iostream>
9#include <string>
10
11int main(int argc, char **argv) {
12 if (!al_init()) return -1; // Is closed automagically at __END__
13 ALLEGRO_EVENT_QUEUE *ev_q = al_create_event_queue(); // Has to be closed before leaving
14 if (!ev_q) return -1;
15 if (!al_install_keyboard()) return -1; // No need for uninstall...
16 al_register_event_source(ev_q , al_get_keyboard_event_source()); // will be unregistered when the event queue is detroyed
17
18 ALLEGRO_EVENT ev; // Swt aside memory for the event structure
19
20 if (!al_install_mouse()) return -1; // No need for uninstall...
21 if (!al_init_image_addon()) return -1; // Is closed automagically at __END__
22 if (!al_init_font_addon()) return -1; // Is closed automagically at __END__
23 if (!al_init_ttf_addon()) return -1; // Is closed automagically at __END__
24 if (!al_init_primitives_addon()) return -1; // Is closed automagically at __END__
25
26 ALLEGRO_TEXTLOG *textwindow = al_open_native_text_log("Text output", ALLEGRO_TEXTLOG_NO_CLOSE); // Closing this is mandatory -)
27
28 int number_modes = al_get_num_display_modes();
29
30 al_append_native_text_log(textwindow, "Counted %d available display modes\n", number_modes); // Write to the text log window with this function
31
32 ALLEGRO_DISPLAY_MODE mode; // Swt aside memory for the mode structure
33
34 int i;
35
36 for (i=0;i<number_modes;i++)
37 {
38 al_get_display_mode(i, &mode);
39 al_append_native_text_log(textwindow, "width: %d height: %d format: %d refesh rate: %d\n", mode.width, mode.height, mode.format, mode.refresh_rate);
40 }
41
42 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); // Set how your main display shall be displayed
43 ALLEGRO_COLOR color_bg = al_map_rgba(100,255,255,255);
44 ALLEGRO_COLOR color_fg1 = al_map_rgba(0,0,0,255);
45 ALLEGRO_COLOR color_fg2 = al_map_rgba(255,255,60,255);
46 ALLEGRO_DISPLAY *display = al_create_display(800,600);
47// Open the main display. Using bitmaps with the display might be a good choice...
48// You should make sure no threads are currently targeting a bitmap which is tied to the display before you destroy it.
49// It is mandatory to destroy it before you exit!
50 al_clear_to_color(color_bg);
51 al_draw_triangle(100.5, 100.5, 499.5, 100.5, 300, 499.5, color_fg1, 11.0);
52 al_draw_triangle(100.5, 100.5, 499.5, 100.5, 300, 499.5, color_fg2, 1.0);
53 al_flip_display();
54
55 do {
56 al_wait_for_event(ev_q , &ev);
57 } while (ev.type != ALLEGRO_EVENT_KEY_DOWN); // the ANYKEY event ;-)
58
59 al_destroy_display(display);
60 al_close_native_text_log(textwindow); // Necessary...
61 al_destroy_event_queue(ev_q); // Necessary destroy. All event sources are destroyed,too. Emptying the queue first may inhibit nasty warnings/errors (who knows ???
62
63 return 0;
64}
When I run it on the CLI I get this message: With gdb as debugger I can't reproduce it. 1(gdb)
263 return 0;
3(gdb)
464 }
5(gdb)
6__libc_start_main (main=0x8048bcd <main(int, char**)>, argc=1, argv=0xbffff024, init=0x8048f60 <__libc_csu_init>, fini=0x8048fd0 <__libc_csu_fini>, rtld_fini=0xb7fed160 <_dl_fini>, stack_end=0xbffff01c)
7 at libc-start.c:321
8321 libc-start.c: Datei oder Verzeichnis nicht gefunden.
9(gdb)
10[Thread 0xb6c1cb40 (LWP 23019) exited]
11[Thread 0xb4affb40 (LWP 23029) exited]
12[Thread 0xb54ffb40 (LWP 23028) exited]
13[Thread 0xb5ea0b40 (LWP 23027) exited]
14[Inferior 1 (process 23001) exited normally]
15(gdb)
16The program is not being run.
17(gdb) quit
The script does exactly what it should do according to documentation snippets I got mostly from this site. It just irks me that SCIM is interfering with Allegro. My compile script is #!/bin/bash echo "*** starting preprocessing... ***" g++ -Wall -Wextra -E -dP -ggdb -o allegro_0.2.ii allegro_0.2.cpp `pkg-config --cflags --libs allegro-5 allegro_main-5 allegro_primitives-5 allegro_dialog-5 allegro_image-5 allegro_ttf-5 allegro_color-5 allegro_font-5` echo "*** starting compiler step... ***" g++ -Wall -Wextra -dP -ggdb -S allegro_0.2.ii -o allegro_0.2.s `pkg-config --cflags --libs allegro-5 allegro_main-5 allegro_primitives-5 allegro_dialog-5 allegro_image-5 allegro_ttf-5 allegro_color-5 allegro_font-5` echo "*** starting linker step... ***" g++ -Wall -Wextra -dP -ggdb -o allegro_0.2 allegro_0.2.s `pkg-config --cflags --libs allegro-5 allegro_main-5 allegro_primitives-5 allegro_dialog-5 allegro_image-5 allegro_ttf-5 allegro_color-5 allegro_font-5` #./allegro1 Thanks in advance for input. AHJ (washuu_de) |
bamccaig
Member #7,536
July 2006
|
Hmmm, I think the display is kind of important. My guess might be that you should create the display before some other stuff... Not sure that should matter. Does the program work properly until a key is pressed? As a side note, its rare to output preprocessed source or assembly. Shouldn't hurt, but a bit strange. Typically people save the objects (-c), but that's to save recompiling them. Just curious what the rationale is. The GDB error suggests you're trying to step into code that you don't have source/debug symbols for. Are you trying to step into third party code? I'm not sure what SCIM is... -- 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 |
washuu_de
Member #16,656
March 2017
|
If I don't open the textlog window and the display window at the same time The program works properly. The message is written when the instruction pointer leaves main at the <}>. SCIM is an input method. I use it to write in Japanese on my German keyboard. About the 3-step compile-link sequence: I want to see all the structures I included AHJ |
|