与DUMB和Allegro链接时未定义的引用

时间:2013-08-06 08:21:20

标签: compilation linker mingw libraries allegro

我已经花了10个小时试图找出这个。我尝试了一堆不同的库,试图让ogg或mp3文件与allegro 4一起玩。我下载了DUMB库,并将include和lib文件复制到mingw各个地方(我使用的是代码块)。 将库安装到编译器的正确方法是什么? 这是我目前的代码..

#include <allegro.h>
#include <iostream>
#include <stdlib.h>
#include <aldumb.h>


#include "CUSTOM_FUNCTIONS_HEADER.h"
#include "status_screen_functions_header.h"

#define WHITE makecol(255,255,255)

//General Game Settings
int volume = 128;
int pan = 128;
int pitch = 1000;

#
int main(int argc, char *argv[]){


    allegro_init();
    atexit(&dumb_exit);//initialize dumb
    dumb_register_stdfiles(); //tELL DUMB HOW TO OPEN FILES

    install_keyboard();
    if(install_sound(DIGI_AUTODETECT, MIDI_NONE, "") != 0){

        allegro_message("error initializing the sound system");

    }


    set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1100, 550, 0, 0);

    write_status_screen("Status$>_Allegro Engine Initialization Successfull");
//******************************************************************************//
//*****************************************************************************//
//Write code below this line since allegro has been initialized//
    BITMAP *dragon;
    BITMAP *main_title, *main_menu;
    BITMAP *buffer;

    /*Menu music*/
   // load_sample("OG_MUSIC\\straight_outta_compton_menu.ogg");

    //Setup Audiostream for Main Menu Music//

    write_status_screen("Status$> Loading OG Music Stream: \"Straight Outta Compton.OGG\"");


    DUH *myduh;

    myduh = dumb_load_it_quick("OG_MUSIC\\straight_outta_compton_menu.ogg");

    AL_DUH_PLAYER *dp = al_start_duh(myduh, 2, 0,
                                  volume, 4096, 48000);;

//logg_get_stream("straight_outta_compton_menu.ogg", volume, pan, true);



    SAMPLE *menu_guntrigger = load_sample("OG_MUSIC\\gun_menu_choose.wav");


    /*Menu count*/
    int menct = 0;

    buffer = create_bitmap(1100, 480);

    textprintf_ex(screen, font, 0, 0, WHITE, 0, "Resolution = %ix%i ", SCREEN_W, SCREEN_H);

    dragon = load_bitmap("BITMAPS\\COMPTON_START_MENU_FADED_TWO.bmp", NULL);
    main_title = load_bitmap("BITMAPS\\OGM_TITLE.bmp", NULL);
    main_menu = load_bitmap("BITMAPS\\MAIN_MENU.bmp", NULL);


    write_status_screen("Status$>_Bitmaps loaded into memory!");
    write_status_screen("Status$> Loading OG Sound Effects......:");
    rest(650);



    rest(700);


    int frames_drawn = 0;

    while(!key[KEY_ESC]){



    /*Handle Controls First modulus 2 to make selection easier, every second frame, keypress is captured. DO NOT DO THIS FOR ACTUAL GAMEPLAY*/

        if(key[KEY_UP] && frames_drawn % 2 == 0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct--;
        } else if (key[KEY_DOWN] && frames_drawn % 3 == 0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct++;
        }
        if (menct > 3){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct = 0;
        }else if (menct <0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct = 3;
        }
        rest(10);


        //Erase everything
        clear(buffer);

        //status box
        rectfill(screen, 0, 480, 1100, 483, WHITE);

        /*Draw the frame based on user input*/
        draw_sprite(buffer, dragon, 0, 0);
        draw_sprite(buffer, main_title, 315, 10);
        drawframe(buffer, main_menu, 485, 145, 332, 305, 0, 0, 4, menct);
        //blit(main_title, screen, 0, 0, 50, 50, 540, 96);
        //masked_blit(main_title, screen, 0, 0, 50, 50, 540, 96);

        //masked_blit(source, dest, framex, framey, x, y, width, height);

        textprintf_ex(buffer, font, 900, 470, WHITE, 0, "Written By: Kelvin Silva", bitmap_color_depth(screen));

        textprintf_ex(buffer, font, 0, 470, WHITE, 0, "Frames Drawn: %i", frames_drawn);

        blit(buffer, screen, 0, 0, 0, 0, 1100, 480);

        /*pollduh*/
        al_poll_duh(dp);
        /*Wait for vsync, rest a little, update framecount and prompt for more input*/
        vsync();
        frames_drawn++;
        rest(50);
    }

    write_status_screen("Status$>_Game Loop Ended...");

    clear_status_screen();
//NOTE NEED TO SETUP MEMORY DESTRUCTION


    destroy_bitmap(dragon);
    destroy_bitmap(main_title);
    destroy_bitmap(buffer);

    allegro_exit();

    return 0;
}
END_OF_MAIN()



d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_start_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|48|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|49|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|62|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|69|undefined reference to `voice_set_priority'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|74|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_stop_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|92|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_pause_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|103|undefined reference to `voice_stop'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_resume_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|113|undefined reference to `voice_start'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_set_priority':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|123|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_poll_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|156|undefined reference to `get_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|166|undefined reference to `free_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|167|undefined reference to `stop_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|179|undefined reference to `free_audio_stream_buffer'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_encapsulate_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|208|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|209|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|215|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|222|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_decompose_to_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|248|undefined reference to `stop_audio_stream'|
||=== Build finished: 18 errors, 0 warnings (0 minutes, 0 seconds) ===|

1 个答案:

答案 0 :(得分:0)

DUMB要求您链接两个库,核心libdumb,然后是aldumb“glue”。看起来你只是与后者联系。订单也很重要。

请注意,DUMB用于播放MOD文件(以及各种变体)。如果您需要ogg支持,如果您安装了官方ogg库,它将在Allegro 4.4中内置。

此外,如果您刚开始使用,那么您应该真正使用Allegro 5.版本4不再受支持,在现代操作系统上也无法正常工作。