简体   繁体   English

使用make编译allegro5程序

[英]Compiling an allegro5 program using make

I have a program called zone.c that uses the allegro5 library. 我有一个名为zone.c的程序,该程序使用allegro5库。

I have a makefile that consists of just these two lines. 我有一个仅由这两行组成的makefile。

zone: zone.c
        gcc zone.c -o zone $(pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0)

when I type "make" I get these errors: 当我键入“ make”时,出现以下错误:

/tmp/ccyCx3Hy.o: In function main': zone.c:(.text+0x14): undefined reference to al_install_system' zone.c:(.text+0x23): undefined reference to al_create_display' zone.c:(.text+0x3b): undefined reference to al_map_rgb' zone.c:(.text+0x70): undefined reference to al_clear_to_color' zone.c:(.text+0x84): undefined reference to al_map_rgb' zone.c:(.text+0xd1): undefined reference to al_draw_filled_circle' zone.c:(.text+0xe5): undefined reference to al_map_rgb' zone.c:(.text+0x132): undefined reference to al_draw_filled_circle' zone.c:(.text+0x137): undefined reference to al_flip_display' zone.c:(.text+0x14f): undefined reference to al_rest' zone.c:(.text+0x15b): undefined reference to al_destroy_display' collect2: error: ld returned 1 exit status make: * [zone] Error 1 /tmp/ccyCx3Hy.o:在函数main': zone.c:(.text+0x14): undefined reference to al_install_system的main': zone.c:(.text+0x14): undefined reference to zone.c :(。text + 0x23):未定义对al_create_display' zone.c:(.text+0x3b): undefined reference to引用al_create_display' zone.c:(.text+0x3b): undefined reference to al_map_rgb'区域的al_create_display' zone.c:(.text+0x3b): undefined reference to 。c :(。text + 0x70):对al_clear_to_color' zone.c:(.text+0x84): undefined reference to未定义引用al_clear_to_color' zone.c:(.text+0x84): undefined reference to al_map_rgb'区域的al_clear_to_color' zone.c:(.text+0x84): undefined reference to .c :(。text + 0xd1):未定义引用al_draw_filled_circle' zone.c:(.text+0xe5): undefined reference to al_map_rgb'区域.c :(。text + 0x132):未定义引用al_draw_filled_circle' zone.c:(.text+0x137): undefined reference to al_flip_display'zone.c :(。text + 0x14f):未定义引用al_rest' zone.c:(.text+0x15b): undefined reference to al_destroy_display'collect2:错误:ld返回1退出状态make: * [区域]错误1

But if I just copy out the line "gcc zone.c -o zone $(pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0)" and run it manually, it compiles fine and the program works. 但是,如果我只复制“ gcc zone.c -o zone $(pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0)”行并手动运行它,则可以正常编译并且该程序可以运行。

If I use similar makefiles to compile programmes that don't use allegro5, then make works. 如果我使用类似的makefile来编译不使用allegro5的程序,请进行编译。

Does anybody have a clue what's going on? 有人知道发生了什么吗?

If you want a literal $ in your rule, you have to escape it from make by writing $$ instead: 如果您想在规则中使用文字$ ,则必须改写$$以使其摆脱make的影响:

zone: zone.c
        gcc zone.c -o zone $$(pkg-config --cflags --libs allegro-5.0 allegro_primitives-5.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM