簡體   English   中英

Allegro:鏈接器未正確鏈接庫[Code :: Blocks]

[英]Allegro: linker does not properly link libraries [Code::Blocks]

我在Code :: Blocks中遇到Allegro 5.0.10庫的問題。 它們似乎無法正確鏈接,因為當我嘗試從Wiki編譯示例時:

#include <stdio.h>
#include <allegro5/allegro.h>

int main(int argc, char **argv)
{

ALLEGRO_DISPLAY *display = NULL;

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

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

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

al_flip_display();

al_rest(10.0);

al_destroy_display(display);

return 0;
}

編譯器給出了一系列錯誤,例如: D:/C++Dev/workspace/Obvi/Main.cpp:10: undefined reference to 'al_install_system' 我試圖通過使用“其他鏈接器選項”鏈接進行修復。 (-lallegro-5.0.10-monolith-static-mt),但隨后鏈接器給出錯誤: D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lallegro-5.0.10-monolith-static-mt 我添加了“搜索目錄”:鏈接程序的庫,包括編譯器的庫。 在構建日志中我還發現: D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:\\C++Dev\\libs\\allegro-5.0.10-mingw-4.7.1-tdm\\lib/liballegro-5.0.10-monolith-static-mt.a when searching for -lallegro-5.0.10-monolith-static-mt ,它告訴鏈接程序找到庫,但是由於某種原因將其忽略。

您是否鏈接了-lalleg庫? 轉到設置->編譯器->鏈接器設置->其他鏈接器選項,然后鍵入-lalleg。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM