I use the g++ compiler for linux and i am trying to link allegro. how do i link allegro with g++?
John A 1,896 Vampirical Lurker Team Colleague
Hello,
I believe you need to use the -lalleg
with g++ to link with the Allegro libraries.
Sturm 270 Veteran Poster
I tried to compile my example file with the following command "g++ new\ file.cpp -o new\ file -lalleg". It returned the usual doesn't recognize my functions etc. Am I missing something?
John A 1,896 Vampirical Lurker Team Colleague
Could you post the exact error messages you get? Are you having undefined functions, or undeclared functions?
You'll also probably need to manually specify libray paths or else g++ won't be able to find them.
Sturm 270 Veteran Poster
This is my run command:
g++ new\ file.cpp -o new\ file -lalleg
This is my code:
#include <allegro.h>
int main(){
allegro_init();
install_keyboard();
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
readkey();
return 0;
}
END_OF_MAIN();
This is my error:
new file.cpp:2:21: error: allegro.h: No such file or directory
new file.cpp: In function ‘int main()’:
new file.cpp:7: error: ‘allegro_init’ was not declared in this scope
new file.cpp:8: error: ‘install_keyboard’ was not declared in this scope
new file.cpp:9: error: ‘GFX_AUTODETECT’ was not declared in this scope
new file.cpp:9: error: ‘set_gfx_mode’ was not declared in this scope
new file.cpp:11: error: ‘readkey’ was not declared in this scope
new file.cpp: At global scope:
new file.cpp:16: error: expected constructor, destructor, or type conversion before ‘;’ token
John A 1,896 Vampirical Lurker Team Colleague
OK, so the compiler can't find the allegro.h file. You need to find out where this file is located on your system, and then tell g++ the location of it:
# g++ new\ file.cpp -o new\ file -I /search/path/here -lalleg
Additionally, use the -L
to specify a library path for lalleg if the linker starts complaining about missing libraries.
Sturm 270 Veteran Poster
The only thing I can find is the my allegro file at "/usr/lib/allegro/4.2/"
There are six files in this directory:
1. alleg-alsadigi.so
2. alleg-alsamidi.so
3. alleg-vga.so
4. alleg-dga2.so
5. alleg-fbcon.so
6. modules.lst
Where is allegro.h?
John A 1,896 Vampirical Lurker Team Colleague
Did you install the developer's version of Allegro? Simply installing the runtime version isn't enough to compile its applications.
So this doesn't turn up anything, does it?
# sudo find / -name allegro.h
Sturm 270 Veteran Poster
I downloaded the dev files for allegro and now when I compile it returns the following
-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_show_mouse':
(.text+0xb0d9): undefined reference to `XDefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_show_mouse':
(.text+0xb10e): undefined reference to `XUndefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_show_mouse':
(.text+0xb11c): undefined reference to `XFreeCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_set_mouse_sprite':
(.text+0xb187): undefined reference to `XcursorImageDestroy'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_set_mouse_sprite':
(.text+0xb1ce): undefined reference to `XcursorImageCreate'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb91f): undefined reference to `XUnmapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb939): undefined reference to `XUngrabPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb960): undefined reference to `XUngrabKeyboard'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb990): undefined reference to `XChangeWindowAttributes'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb9b3): undefined reference to `XShmDetach'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xb9eb): undefined reference to `XF86VidModeLockModeSwitch'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_destroy_screen':
(.text+0xba03): undefined reference to `XF86VidModeSwitchToMode'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_set_matching_colors':
(.text+0xbd8b): undefined reference to `XStoreColors'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbe64): undefined reference to `XUnmapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbe76): undefined reference to `XResizeWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbe85): undefined reference to `XMapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbe8a): undefined reference to `XAllocSizeHints'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbec3): undefined reference to `XSetWMNormalHints'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbecb): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xbf5a): undefined reference to `XCreateImage'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc06d): undefined reference to `XAllocColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc0b8): undefined reference to `XAllocColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc106): undefined reference to `XAllocColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc154): undefined reference to `XAllocColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc1a2): undefined reference to `XAllocColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o):(.text+0xc1f0): more undefined references to `XAllocColor' follow
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc6d1): undefined reference to `XChangeWindowAttributes'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc73c): undefined reference to `XF86VidModeQueryExtension'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc7f0): undefined reference to `XF86VidModeQueryVersion'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xc81b): undefined reference to `XF86VidModeGetAllModeLines'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_private_create_screen':
(.text+0xcc14): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xd274): undefined reference to `XShmQueryExtension'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xd2b4): undefined reference to `XShmCreateImage'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xd329): undefined reference to `XShmAttach'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xd347): undefined reference to `XSync'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xda28): undefined reference to `XF86VidModeSwitchToMode'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xda48): undefined reference to `XF86VidModeLockModeSwitch'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xda68): undefined reference to `XMoveWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xda7b): undefined reference to `XF86VidModeSetViewPort'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdb3f): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdb4c): undefined reference to `XSync'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdb55): undefined reference to `XDefaultRootWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdb68): undefined reference to `XGrabKeyboard'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdb9f): undefined reference to `XGrabPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdbe5): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdc07): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdc2e): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdc4f): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdef7): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xdf7a): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `.L2215':
(.text+0xe001): undefined reference to `XStoreColor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe4ac): undefined reference to `XcursorImageDestroy'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe4cf): undefined reference to `XFreeGC'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe51a): undefined reference to `XUndefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe528): undefined reference to `XFreeCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe547): undefined reference to `XUnmapWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe555): undefined reference to `XDestroyWindow'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe56c): undefined reference to `XUninstallColormap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_destroy_window':
(.text+0xe57a): undefined reference to `XFreeColormap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_close_display':
(.text+0xe5e8): undefined reference to `XCloseDisplay'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_open_display':
(.text+0xe687): undefined reference to `XOpenDisplay'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xwin.o): In function `_xwin_open_display':
(.text+0xe69b): undefined reference to `XDefaultScreen'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x3e): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x52): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_unload_modules':
(.text+0x77): undefined reference to `dlclose'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_load_modules':
(.text+0x2b9): undefined reference to `dlopen'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(umodules.o): In function `_unix_load_modules':
(.text+0x2d5): undefined reference to `dlsym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_exit':
(.text+0x30): undefined reference to `pthread_join'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_init':
(.text+0x6d): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uptimer.o): In function `ptimer_thread_func':
(.text+0xb8): undefined reference to `pthread_sigmask'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_exit':
(.text+0x55a): undefined reference to `pthread_join'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_init':
(.text+0x690): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(uthreads.o): In function `bg_man_pthreads_threadfunc':
(.text+0x6f9): undefined reference to `pthread_sigmask'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_set_leds':
(.text+0x109): undefined reference to `XChangeKeyboardControl'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_set_leds':
(.text+0x132): undefined reference to `XChangeKeyboardControl'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_set_leds':
(.text+0x14d): undefined reference to `XChangeKeyboardControl'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_exit':
(.text+0x1db): undefined reference to `XDestroyIC'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_exit':
(.text+0x1fb): undefined reference to `XCloseIM'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_exit':
(.text+0x21b): undefined reference to `XFreeModifiermap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_exit':
(.text+0x23b): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `find_unknown_key_assignment':
(.text+0x34f): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `find_unknown_key_assignment':
(.text+0x396): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x446): undefined reference to `XDisplayKeycodes'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x46a): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x493): undefined reference to `XGetKeyboardMapping'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x522): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x52a): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x56d): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x5d4): undefined reference to `XFreeModifiermap'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x5ea): undefined reference to `XGetModifierMapping'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x635): undefined reference to `XKeycodeToKeysym'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_get_keyboard_mapping':
(.text+0x63d): undefined reference to `XKeysymToString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_init':
(.text+0x7db): undefined reference to `XOpenIM'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_init':
(.text+0x802): undefined reference to `XGetIMValues'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_init':
(.text+0x911): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_init':
(.text+0x945): undefined reference to `XCreateIC'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `x_keyboard_init':
(.text+0x98d): undefined reference to `XFree'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_keyboard_handler':
(.text+0x13ca): undefined reference to `Xutf8LookupString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_keyboard_handler':
(.text+0x140f): undefined reference to `XFilterEvent'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xkeyboard.o): In function `_xwin_keyboard_handler':
(.text+0x17fb): undefined reference to `XLookupString'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xmouse.o): In function `_xwin_select_system_cursor':
(.text+0x93): undefined reference to `XCreateFontCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xmouse.o): In function `_xwin_select_system_cursor':
(.text+0xa6): undefined reference to `XDefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xmouse.o): In function `_xwin_select_system_cursor':
(.text+0xea): undefined reference to `XUndefineCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xmouse.o): In function `_xwin_select_system_cursor':
(.text+0xf8): undefined reference to `XFreeCursor'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xmouse.o): In function `_xwin_mousedrv_position':
(.text+0x3a2): undefined reference to `XWarpPointer'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_clear_to_color':
(.text+0x1884): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_clear_to_color':
(.text+0x18b6): undefined reference to `XFillRectangle'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_rectfill':
(.text+0x1ace): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_rectfill':
(.text+0x1afb): undefined reference to `XFillRectangle'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_vline':
(.text+0x1d74): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_vline':
(.text+0x1d99): undefined reference to `XDrawLine'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_hline':
(.text+0x1f8b): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_hline':
(.text+0x1fa8): undefined reference to `XDrawLine'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_putpixel':
(.text+0x2151): undefined reference to `XSetForeground'
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/liballeg.a(xvtable.o): In function `_xwin_putpixel':
(.text+0x2166): undefined reference to `XDrawPoint'
collect2: ld returned 1 exit status
there is more errors but they are all alike
I did the command
sudo find / -name allegro.h
it finds stuff but what do I do now?
blacklight 0 Newbie Poster
it finds stuff but what do I do now?
For the X errors, add
-L/usr/X11R6/lib -lX11
probably "-lXext -lXmu" may be also needed, but I saying that from memory of x-windows compilation, I dont have linux hands-on experience with allegro.
Sturm 270 Veteran Poster
I tried adding the above to my compiling command but it still does not work. Is there some tutorial somewhere that will tell me how to do this?
John A 1,896 Vampirical Lurker Team Colleague
You're obviously missing some libraries that Allegro depends on. What does the README/INSTALL/COMPILING file say?
When you run ./configure, what errors does it bring up? If there are none, compilation should go easily. If not, make sure all the libraries listed in the documentation are installed on your system.
Sturm 270 Veteran Poster
ok I followed the documentations instructions. My process is as follows
1. I downloaded the allegro source
2. I unziped it
3. I ran ./cconfigure
4. I ran make
5. I ran su -c "make install" as root
6. then I compiled with the command g++ new\ file.cpp -o myprogram `allegro-config --libs`
When I try to run it nothing happens. Any ideas? And how do you make those back tics?
John A 1,896 Vampirical Lurker Team Colleague
At least you've got Allegro installed (we think). So no errors occur when you try to compile the program, then?
What happens if you use the command I previsouly suggested to you on manually specifying library and header paths. Does that work?
Sturm 270 Veteran Poster
To answer your question yes it compiles. I presume you mean the command "-lalleg"? It returns the same errors as above. Maybe it has to do with the config file that lets me not have to include thousands of header files? Or do you mean specifing the directory of each header file? would the command be something like this "-l/usr/include/allegro.h" or something else?
John A 1,896 Vampirical Lurker Team Colleague
To answer your question yes it compiles.
OK, hold on a sec. Do you mean "program" as in Allegro, or as in the program that uses Allegro that you were originally trying to compile. Sorry about not being clearer about my question in the first place, but I kind of meant the program that you were originally trying to compile.
I presume you mean the command "-lalleg"? It returns the same errors as above. Maybe it has to do with the config file that lets me not have to include thousands of header files? Or do you mean specifing the directory of each header file?
Sort of both. You definitely won't be able to link your program without -lalleg, but it's also quite possible you'll need to manually specify library/header paths.
Just for the record, what errors does it show when you try to compile your original program? If it does compile, what happens when you try to run it? Nothing?
would the command be something like this "-l/usr/include/allegro.h" or something else?
Yes, and you might need a similar one for -L and the library path of allgero.
Sturm 270 Veteran Poster
Yes the program I wrote named new file.cpp compiles with the command
g++ new\ file.cpp -o myprogram `allegro-config --libs`
When I run it nothing happens. does have to do with it does not no what to run it with (kinda like when you try to run program that uses the terminal without one)?
John A 1,896 Vampirical Lurker Team Colleague
Why are you using backticks when you issue the command (`)? I think you should be using single quotes ('). And do you still get the same errors as before when you manually specify library/header paths?
Maybe this will help you:
http://www.talula.demon.co.uk/allegro/faq.html#When_I_try_to_compile_a_program_using_Allegro__I_get_lots_of_errors_like_
Sturm 270 Veteran Poster
I decided to run make install again just to make sure everything was installed. When I ran it I incountered a warning that I missed before:
Warning: shared library destination /usr/local/lib is not in ldd search path.
Unless you add it to /etc/ld.so.conf, you must set LD_LIBRARY_PATH to include
/usr/local/lib each time you want to run an Allegro program.
I looked under /etc/ but I could not find the file ld.so.cnf. How do I fix this error? what is LD_LIBRARY_PATH? Sorry if this is a stupid question.
Sturm 270 Veteran Poster
I give up! Is there a graphics library for g++ thats as easy as allegro?
John A 1,896 Vampirical Lurker Team Colleague
I decided to run make install again just to make sure everything was installed. When I ran it I incountered a warning that I missed before:
Warning: shared library destination /usr/local/lib is not in ldd search path. Unless you add it to /etc/ld.so.conf, you must set LD_LIBRARY_PATH to include /usr/local/lib each time you want to run an Allegro program.
I looked under /etc/ but I could not find the file ld.so.cnf.
Hmm, it should be somewhere on your system. Did you try this?
$ su
[enter password]
# find / -name ld.so.conf
If it doesn't turn up anything, don't panic. I believe my Gentoo system didn't contain one originally, so I had to manually create one. For now, just create a file like this:
# start of etc/ld.so.conf
/usr/local/lib
/lib
# add any directories here
Save this file as /etc/ld.so.conf (you'll need root privalges), and then update it with ldconfig:
# ldconfig
what is LD_LIBRARY_PATH?
It's the paths that the linker checks for libraries. For example, you want it to link with the file libglib.so. Well, it's not going to scour the hard drive looking for the file, so you're going to have to tell it which directories to look in. LD_LIBRARY_PATH
is a Unix variable that contains this list.
To see which paths are currently set, do this:
# echo $LD_LIBRARY_PATH
You can add to this manually before you compile or run an Allegro app like this:
# LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/local/lib:/lib
As you can see, the directory entries are seperated by a colon. Add as many as you want, although it's reset everytime you turn off or reboot your machine.
John A 1,896 Vampirical Lurker Team Colleague
I give up! Is there a graphics library for g++ thats as easy as allegro?
I wouldn't put the blame on Allegro :). The problems you're experiencing are the problems trying to connect another library with your program. There's always going to be problems.
So believe me, this problem is quite frequent. I've experienced this problem on all platforms (Mac, *nix, and Windows). And I'm sure even most experts have had this problem at some point, too. Another thing: using a different library is *not* going to help. If you can't get g++ to find Allegro libraries, chances are you can't make it find any libraries, so if you're serious about Allegro, keep trying and you'll get it eventually. ;)
Sturm 270 Veteran Poster
I checked again and I found the ld.so.conf so I added at the end /usr/local/lib. I then ran ldconfig as root. When I use the command:
"g++ new\ file.cpp -o myprogram -lalleg" it returns the following:
/usr/bin/ld: cannot find -lalleg
collect2: ld returned 1 exit status
But when I use the command "g++ new\ file -o myprogram `allegro-config --libs` as it said to do in the allegro tutorial I read, it compiles.
I tried to do the command:
"LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/local/lib:/lib"
It returns the following:
bash: LD_LIBRARY_PATH: command not found
Why does this not work?
John A 1,896 Vampirical Lurker Team Colleague
I checked again and I found the ld.so.conf so I added at the end /usr/local/lib. I then ran ldconfig as root. When I use the command:
"g++ new\ file.cpp -o myprogram -lalleg" it returns the following:/usr/bin/ld: cannot find -lalleg collect2: ld returned 1 exit status
The linker can't find the libraries needed. Just out of interest, do you get different errors when trying to compile a C program using Allegro with gcc
?
But when I use the command "g++ new\ file -o myprogram `allegro-config --libs` as it said to do in the allegro tutorial I read, it compiles.
Somehow I don't buy that. It says right here:
Second, if you are compiling from the command prompt or with a makefile, add
-lalleg
to the end of your gcc command line, or if you are using Rhide, go to the Options/Libraries menu, typealleg
into the first empty field, and make sure the box next to it is checked.
I tried to do the command:
"LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/local/lib:/lib"
It returns the following:bash: LD_LIBRARY_PATH: command not found
Why does this not work?
Oops, sorry!
The spaces are messing up bash, and you might also want to export it:
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/lib
Then double-check that it looks correct:
# echo $LD_LIBRARY_PATH
And by the way, where does liballeg.a
reside on your system?
Sturm 270 Veteran Poster
Yes it is back ticks.
The options for linking with Allegro are quite complicated, since for static versions of the library, depending on how it was configured, it may need to pull in other libraries (X, SVGAlib), as well as just Allegro itself, and for all versions the library is split into two chunks -- one of which is always static, and the other of which is sometimes shared. To avoid you having to work out the right linker commands for yourself, the installation creates a script, allegro-config, that will print out a suitable commandline. You can use this inside a backtick command substitution, for example:
gcc myfile.c -o myprogram `allegro-config --libs`
Or if you want to build a debug version of your program, assuming that you have installed the debug version of Allegro: gcc myfile.c -o myprogram `allegro-config --libs debug`
Unix newbies, take note that these are ` backticks, not normal ' quotes!
ARE YOU A UNIX NEWBIE!?:cheesy:
When I do the command "echo LD_LIBRARY_PATH" it returns "LD_LIBRARY_PATH". Is this what is supposed to happen?
Yes the results when I compile a c++ program with g++ and c program with gcc are identical.
liballeg.a resides in /usr/lib/ But it is a archived file. Should it be archived?
John A 1,896 Vampirical Lurker Team Colleague
Yes it is back ticks.
ARE YOU A UNIX NEWBIE!?:cheesy:
Ah, I kind of read the command a bit fast. What the backticks essentially do here is run another command, "allegro-config", which generates the necessary libraries to link with your program.
Could you post the result of running this at the shell:
# allegro-config --libs
When I do the command "echo LD_LIBRARY_PATH" it returns "LD_LIBRARY_PATH". Is this what is supposed to happen?
You're obviously not entering the $ symbol, which tells to shell to print out the variable, and not the string, LD_LIBRARY_PATH. The command should look like this:
# echo $LD_LIBRARY_PATH
liballeg.a resides in /usr/lib/ But it is a archived file. Should it be archived?
If the filename is "liballeg.a" and nothing else, it's not an archived file. Your file browser may be fooling you. If it's got tar.bz2 or some other extension after it (it shouldn't), then yes you might need to extract it.
Sturm 270 Veteran Poster
Stupid browser.
When I run the command "allegro-config --libs" it returns:
-L/usr/local/lib -Wl,--export-dynamic -lalleg-4.2.1 -lalleg_unsharable
Funny, but when I run the above output with -lalleg at the end it no longer complains about not being able to find a -lalleg.
John A 1,896 Vampirical Lurker Team Colleague
Well, at least your program compiles and links (we think).
Now I think it's some sort of runtime error. I know you're statically linking, but could you try to see if a liballeg.so file exists on your system?
So absoloutely nothing happens when you try to run it - that is, it quits immediately after being invoked? Is there any output if you run it on the console?
You may also need OpenGL drivers/Mesa3D installed on your system.
Sturm 270 Veteran Poster
Two files called liballeg.so.4.2 and liballeg-4.2.so both are under /usr/lib/
If I run it in a console with the command "sh myprogram" it returns:
myprogram: 1: Syntax error: "(" unexpected
If I run it by the console with the command "./myprogram" it returns nothing.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.