c - Allegro 5.2 编译错误

标签 c windows allegro5

我一直在尝试使用 Allegro 版本 5.2,但由于某种原因,我无法使用 MinGW 在我的系统(运行 Windows 10 64 位)上编译它。

My Linker Settings

这是我要链接的内容。根据维基,这应该是正确的,但是每当我尝试编译示例代码时,我都会收到诸如

之类的错误
src\game.c|13|undefined reference to `al_clear_to_color'|

据我所知,这个功能应该存在。

我真的很感谢任何帮助:)

这是无法编译的代码示例

#include"../include/init.h"

#include "allegro5/allegro5.h"
#include"allegro5/allegro_audio.h"
#include"allegro5/allegro_acodec.h"
#include<stdio.h>
#include<stdlib.h>

const float fps = 30;
const int width = 256;
const int height = 240;

int init() {
    running = 1;

    if(!al_init()) {
        fprintf(stderr, "failed to initialize allegro!\n");
        return -1;
    }

    timer = al_create_timer(1.0 / fps);
    if(!timer) {
        fprintf(stderr, "failed to create timer!\n");
        return -1;
    }

    display = al_create_display(width, height);
    if(!display) {
        fprintf(stderr, "failed to create display!\n");
        return -1;
    }

    event_queue = al_create_event_queue();
    if(!event_queue) {
        fprintf(stderr, "failed to create event_queue!\n");
        return -1;
    }

    /*if(!al_install_audio()){
        fprintf(stderr, "failed to initialize audio!\n");
        return -1;
    }

    if(!al_install_keyboard()) {
        fprintf(stderr, "failed to initialize the keyboard!\n");
        return -1;
    }

    if(!al_init_acodec_addon()){
        fprintf(stderr, "failed to initialize audio codecs!\n");
        return -1;
    }

    if (!al_reserve_samples(1)){
        fprintf(stderr, "failed to reserve samples!\n");
        return -1;
    }*/

    if(!al_init_primitives_addon()) {
        fprintf(stderr, "failed to create primitives addon");
        return -1;
    }


    al_register_event_source(event_queue, al_get_display_event_source(display));

    // register timer event for max fps
    al_register_event_source(event_queue, al_get_timer_event_source(timer));
    //al_register_event_source(event_queue, al_get_keyboard_event_source());

    al_clear_to_color(al_map_rgb(0,0,0));

    al_flip_display();

    al_start_timer(timer);

    return 1;
}

最佳答案

是否使用al_map_rgb_f()函数来映射颜色,如下所示:al_clear_to_color(al_map_rgb(255, 255, 255));

您可以在这里插入您的代码吗?

抱歉,这不应该是一个答案,因为虽然我没有评论它的声誉。

关于c - Allegro 5.2 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38084700/

相关文章:

c - C语言中如何获取子串?

windows - 通过修改 "start in"更改 Jupyter Notebook 启动文件夹不再起作用

multithreading - 通过设置亲和性在单核上运行多线程程序的性能?

c++ - 想要一些文字在游戏中抹去自己

可变参数的 C 宏

c - C中的冒泡排序

windows - 3D 应用程序中鼠标输入的帧率不均匀

c# - 编译基于 C# 的 Windows (WinForms App) 应用程序以在 Mac OS High Sierra 或 Mojave 上运行

在 Allegro 中创建弹丸轨迹

c - 在 switch 的情况下使用定义的字符