Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » linking on ubuntu

This thread is locked; no one can reply to it. rss feed Print
linking on ubuntu
William Labbett
Member #4,486
March 2004
avatar

Hi,

I'm posting here mainly because I've lost my login info for discord and I don't know what to do about that. I'm hoping someone patient can help me.

I've got a makefile which is :

#SelectExpand
1#Makefile for ball_game 2 3 4 5 6 7 8 9 10ball_game : ball_game.o stack.o line_segment.o balls.o Makefile 11 gcc -o ball_game ball_game.o stack.o line_segment.o balls.o $(pkg-config --libs --cflags allegro-5 allegro_main-5 allegro_font-5 allegro_image-5 allegro_primitives-5 ) 12 13 14 15 16 17ball_game.o : ball_game.c line_segment.h balls.h stack.h Makefile 18 gcc -c ball_game.c $(pkg-config allegro-5 allegro_font-5 --libs --cflags) 19 20 21stack.o : stack.c Makefile 22 gcc -c stack.c $(pkg-config allegro-5 allegro_font-5 --libs --cflags) 23 24 25 26balls.o : balls.c balls.h Makefile 27 gcc -c balls.c $(pkg-config allegro-5 allegro_font-5 --libs --cflags) 28 29 30line_segment.o : line_segment.c Makefile 31 gcc -c line_segment.c $(pkg-config allegro-5 allegro_font-5 --libs --cflags) 32 33 34.PHONY: clean 35 36clean : 37 del ball_game.o

and when I call make -f Makefile_linux I get

#SelectExpand
1william@william-MS-7B49:~/projects/ball_game_feb_2024_linux$ make -f Makefile_linux 2gcc -o ball_game ball_game.o stack.o line_segment.o balls.o 3ball_game.o: In function `main': 4ball_game.c:(.text+0x118): undefined reference to `al_install_system' 5ball_game.c:(.text+0x124): undefined reference to `al_load_config_file' 6ball_game.c:(.text+0x151): undefined reference to `al_get_config_value' 7ball_game.c:(.text+0x1b7): undefined reference to `al_fopen' 8ball_game.c:(.text+0x21e): undefined reference to `al_fprintf' 9ball_game.c:(.text+0x22a): undefined reference to `al_fclose' 10ball_game.c:(.text+0x264): undefined reference to `al_fprintf' 11ball_game.c:(.text+0x291): undefined reference to `al_fprintf' 12ball_game.c:(.text+0x326): undefined reference to `al_fprintf' 13ball_game.c:(.text+0x3ee): undefined reference to `al_fprintf' 14ball_game.c:(.text+0x476): undefined reference to `al_fprintf' 15ball_game.c:(.text+0x482): undefined reference to `al_fclose' 16ball_game.c:(.text+0x4c8): undefined reference to `al_fprintf' 17ball_game.c:(.text+0x4d2): undefined reference to `al_set_new_display_flags' 18ball_game.c:(.text+0x4e9): undefined reference to `al_create_display' 19ball_game.c:(.text+0x529): undefined reference to `al_set_display_flag' 20ball_game.c:(.text+0x52e): undefined reference to `al_init_primitives_addon' 21ball_game.c:(.text+0x54b): undefined reference to `al_init_image_addon' 22ball_game.c:(.text+0x550): undefined reference to `al_init_font_addon' 23ball_game.c:(.text+0x555): undefined reference to `al_install_keyboard' 24ball_game.c:(.text+0x55a): undefined reference to `al_init_primitives_addon' 25ball_game.c:(.text+0x55f): undefined reference to `al_install_joystick' 26ball_game.c:(.text+0x569): undefined reference to `al_set_new_display_flags' 27ball_game.c:(.text+0x57f): undefined reference to `al_load_font' 28ball_game.c:(.text+0x5a0): undefined reference to `al_get_joystick' 29ball_game.c:(.text+0x5ba): undefined reference to `al_get_display_height' 30ball_game.c:(.text+0x5cb): undefined reference to `al_get_display_width' 31ball_game.c:(.text+0x628): undefined reference to `al_destroy_display' 32ball_game.c:(.text+0x65e): undefined reference to `al_destroy_display' 33ball_game.c:(.text+0x694): undefined reference to `al_destroy_display' 34ball_game.c:(.text+0x6ca): undefined reference to `al_destroy_display' 35ball_game.c:(.text+0x700): undefined reference to `al_destroy_display' 36ball_game.o:ball_game.c:(.text+0x736): more undefined references to `al_destroy_display' follow 37ball_game.o: In function `main': 38ball_game.c:(.text+0x85c): undefined reference to `al_fclose' 39ball_game.o: In function `run_game_loop': 40ball_game.c:(.text+0x914): undefined reference to `al_create_event_queue' 41ball_game.c:(.text+0x920): undefined reference to `al_create_event_queue' 42ball_game.c:(.text+0x942): undefined reference to `al_create_timer' 43ball_game.c:(.text+0x964): undefined reference to `al_create_timer' 44ball_game.c:(.text+0xb75): undefined reference to `al_create_bitmap' 45ball_game.c:(.text+0xc26): undefined reference to `al_map_rgb' 46ball_game.c:(.text+0xcde): undefined reference to `al_get_display_flags' 47ball_game.c:(.text+0xe27): undefined reference to `al_create_bitmap' 48ball_game.c:(.text+0xe5a): undefined reference to `al_set_target_bitmap' 49ball_game.c:(.text+0xea0): undefined reference to `al_draw_bitmap_region' 50ball_game.c:(.text+0xfb0): undefined reference to `al_get_joystick_event_source' 51ball_game.c:(.text+0xfc5): undefined reference to `al_register_event_source' 52ball_game.c:(.text+0xfca): undefined reference to `al_get_keyboard_event_source' 53ball_game.c:(.text+0xfdf): undefined reference to `al_register_event_source' 54ball_game.c:(.text+0xfee): undefined reference to `al_get_timer_event_source' 55ball_game.c:(.text+0x1003): undefined reference to `al_register_event_source' 56ball_game.c:(.text+0x1012): undefined reference to `al_get_timer_event_source' 57ball_game.c:(.text+0x1027): undefined reference to `al_register_event_source' 58ball_game.c:(.text+0x1039): undefined reference to `al_get_display_event_source' 59ball_game.c:(.text+0x104e): undefined reference to `al_register_event_source' 60ball_game.c:(.text+0x105d): undefined reference to `al_start_timer' 61ball_game.c:(.text+0x106c): undefined reference to `al_start_timer' 62ball_game.c:(.text+0x1080): undefined reference to `al_set_target_bitmap' 63ball_game.c:(.text+0x1094): undefined reference to `al_map_rgb' 64ball_game.c:(.text+0x10d0): undefined reference to `al_clear_to_color' 65ball_game.c:(.text+0x10d5): undefined reference to `al_flip_display' 66ball_game.c:(.text+0x10f5): undefined reference to `al_is_event_queue_empty' 67ball_game.c:(.text+0x1112): undefined reference to `al_wait_for_event' 68ball_game.c:(.text+0x112e): undefined reference to `al_flush_event_queue' 69ball_game.c:(.text+0x1147): undefined reference to `al_get_next_event' 70ball_game.c:(.text+0x121a): undefined reference to `al_get_timer_count' 71ball_game.c:(.text+0x1258): undefined reference to `al_get_timer_count' 72ball_game.c:(.text+0x12bd): undefined reference to `al_set_display_flag' 73ball_game.c:(.text+0x12e5): undefined reference to `al_set_display_flag' 74ball_game.c:(.text+0x1311): undefined reference to `al_get_timer_count' 75ball_game.c:(.text+0x132f): undefined reference to `al_get_timer_count' 76ball_game.c:(.text+0x134d): undefined reference to `al_get_timer_count' 77ball_game.c:(.text+0x136b): undefined reference to `al_get_timer_count' 78ball_game.c:(.text+0x1527): undefined reference to `al_acknowledge_resize' 79ball_game.c:(.text+0x153f): undefined reference to `al_is_event_queue_empty' 80ball_game.c:(.text+0x1565): undefined reference to `al_get_timer_count' 81ball_game.c:(.text+0x19aa): undefined reference to `al_get_timer_count' 82ball_game.c:(.text+0x19dc): undefined reference to `al_get_timer_count' 83ball_game.c:(.text+0x1a0e): undefined reference to `al_get_timer_count' 84ball_game.c:(.text+0x1a40): undefined reference to `al_get_timer_count' 85ball_game.o:ball_game.c:(.text+0x1b47): more undefined references to `al_get_timer_count' follow 86ball_game.o: In function `run_game_loop': 87ball_game.c:(.text+0x1d3f): undefined reference to `al_set_target_bitmap' 88ball_game.c:(.text+0x1d53): undefined reference to `al_map_rgb' 89ball_game.c:(.text+0x1d8f): undefined reference to `al_clear_to_color' 90ball_game.c:(.text+0x1dd5): undefined reference to `al_draw_bitmap' 91ball_game.c:(.text+0x1f96): undefined reference to `al_draw_scaled_bitmap' 92ball_game.c:(.text+0x1faa): undefined reference to `al_map_rgb' 93ball_game.c:(.text+0x202e): undefined reference to `al_draw_pixel' 94ball_game.c:(.text+0x2042): undefined reference to `al_map_rgb' 95ball_game.c:(.text+0x215e): undefined reference to `al_draw_line' 96ball_game.c:(.text+0x21ba): undefined reference to `al_map_rgb' 97ball_game.c:(.text+0x2225): undefined reference to `al_draw_textf' 98ball_game.c:(.text+0x2253): undefined reference to `al_set_target_backbuffer' 99ball_game.c:(.text+0x22c3): undefined reference to `al_draw_scaled_bitmap' 100ball_game.c:(.text+0x22d7): undefined reference to `al_map_rgb' 101ball_game.c:(.text+0x234e): undefined reference to `al_draw_textf' 102ball_game.c:(.text+0x2372): undefined reference to `al_map_rgb' 103ball_game.c:(.text+0x23e5): undefined reference to `al_draw_textf' 104ball_game.c:(.text+0x23ea): undefined reference to `al_flip_display' 105ball_game.o: In function `draw_pendulum': 106ball_game.c:(.text+0x24bd): undefined reference to `al_map_rgb' 107ball_game.c:(.text+0x2559): undefined reference to `al_draw_line' 108ball_game.c:(.text+0x256d): undefined reference to `al_map_rgb' 109ball_game.c:(.text+0x25d6): undefined reference to `al_draw_filled_circle' 110ball_game.o: In function `update_pendulum': 111ball_game.c:(.text+0x2640): undefined reference to `sqrt' 112ball_game.c:(.text+0x265e): undefined reference to `cos' 113ball_game.c:(.text+0x2673): undefined reference to `sin' 114ball_game.c:(.text+0x26cd): undefined reference to `sqrt' 115ball_game.c:(.text+0x26eb): undefined reference to `cos' 116ball_game.c:(.text+0x2700): undefined reference to `cos' 117ball_game.o: In function `update_pendulum_2': 118ball_game.c:(.text+0x2749): undefined reference to `sqrt' 119ball_game.c:(.text+0x2780): undefined reference to `cos' 120ball_game.c:(.text+0x2795): undefined reference to `sin' 121ball_game.c:(.text+0x27d9): undefined reference to `cos' 122ball_game.c:(.text+0x27ee): undefined reference to `cos' 123ball_game.o: In function `update_ball_3': 124ball_game.c:(.text+0x288f): undefined reference to `cos' 125ball_game.c:(.text+0x28e5): undefined reference to `sin' 126ball_game.c:(.text+0x2a56): undefined reference to `tan' 127ball_game.c:(.text+0x2af2): undefined reference to `cos' 128ball_game.c:(.text+0x2b11): undefined reference to `pow' 129ball_game.c:(.text+0x2c16): undefined reference to `cos' 130ball_game.c:(.text+0x2c96): undefined reference to `cos' 131ball_game.o: In function `draw_ball': 132ball_game.c:(.text+0x2d68): undefined reference to `al_draw_filled_circle' 133ball_game.o: In function `load_bitmaps': 134ball_game.c:(.text+0x2d84): undefined reference to `al_load_bitmap' 135ball_game.c:(.text+0x2db5): undefined reference to `al_load_bitmap' 136ball_game.c:(.text+0x2de3): undefined reference to `al_load_bitmap' 137ball_game.o: In function `get_monitor': 138ball_game.c:(.text+0x2e35): undefined reference to `al_get_monitor_info' 139ball_game.o: In function `get_ball_line_segment_collision_info': 140ball_game.c:(.text+0x2ee2): undefined reference to `cos' 141ball_game.c:(.text+0x2f40): undefined reference to `cos' 142ball_game.c:(.text+0x2ff7): undefined reference to `cos' 143ball_game.c:(.text+0x302e): undefined reference to `cos' 144ball_game.c:(.text+0x31e1): undefined reference to `cos' 145ball_game.o:ball_game.c:(.text+0x3218): more undefined references to `cos' follow 146ball_game.o: In function `get_ball_line_segment_collision_info': 147ball_game.c:(.text+0x3337): undefined reference to `sin' 148ball_game.c:(.text+0x33f4): undefined reference to `sin' 149ball_game.c:(.text+0x3410): undefined reference to `sin' 150ball_game.c:(.text+0x3486): undefined reference to `sin' 151ball_game.c:(.text+0x34a2): undefined reference to `sqrt' 152ball_game.c:(.text+0x35f7): undefined reference to `sin' 153ball_game.c:(.text+0x3613): undefined reference to `sin' 154ball_game.c:(.text+0x36aa): undefined reference to `sin' 155ball_game.c:(.text+0x36c6): undefined reference to `sqrt' 156ball_game.o: In function `get_aim_line_x_y_offset': 157ball_game.c:(.text+0x385c): undefined reference to `cos' 158ball_game.c:(.text+0x3886): undefined reference to `cos' 159collect2: error: ld returned 1 exit status 160Makefile_linux:13: recipe for target 'ball_game' failed 161make: *** [ball_game] Error 1 162william@william-MS-7B49:~/projects/ball_game_feb_2024_linux$

It's evident that the allegro libraries aren't getting linked and also some other functions from the C standard library aren't either. Can anyone see what I need to do?

[EDIT : I've found out I need to use -lm for the math library but I don't know how to link the allegro libraries still)

[EDIT 2] : just found I need to use backticks instead of $ and brackets. I've got it working.

Go to: