Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've tried installing allegro library on my system.I didn't get any error while installing the library, but it seems that something went wrong while installation. My code along with the errors I'm getting while compiling the program:

    /* testprog.c */

#include <allegro.h>

void init();
void deinit();

int main() {
init();

while (!key[KEY_ESC]) {
/* put your code here */
}

deinit();
return 0;
}
END_OF_MAIN()

void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}

install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
}

void deinit() {
clear_keybuf();
/* add other deinitializations here */
}


Errors I'm getting:

$ gcc testprog.c -o testprog `allegro-config --cflags --libs`
testprog.c: In function ‘init’:
testprog.c:26:1: warning: format not a string literal and no format arguments [-Wformat-security]
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
$

I've followed instructions given on these links for installing the library and compiling my program:

Instructions for installing allegro on ubuntu

Instructions for compiling programs written in allegro

share|improve this question
    
The question is missing the important text. There are no links. Please check the question again. –  green7 Mar 21 '13 at 19:35
    
oh! sorry! my mistake! let me edit it –  Upasana Mar 21 '13 at 19:36
    
what is END_OF_MAIN() ? –  green7 Mar 21 '13 at 19:45
    
It is predefined macro,in order to maintain cross-platform compatibility, you have to put this macro at the very end of your main function, please check this: allegro.cc/manual/4/api/using-allegro/end_of_main –  Upasana Mar 21 '13 at 19:50
    
It's for allegro 4, right? –  int_ua Nov 20 at 17:19

1 Answer 1

allegro_message() outputs a message, using a printf() format string.

The error is in the line:

allegro_message(allegro_error);

Change it to:

allegro_message("%s\n", allegro_error);
share|improve this answer
    
Still getting the same error :( –  Upasana Mar 21 '13 at 20:00
    
Let's continue this discussion on chat –  green7 Mar 21 '13 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.