本文介绍了Allegro在Ubuntu中:未定义引用`al_install_system'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图安装Allegro库。我有相同的C ++经验,但似乎我没有做这样的东西。我从源编译Allegro 5.0,并将其放在/usr/lib/gcc/i486-linux-gnu/4.4/include/allegro5中。但是当我尝试编译我的代码时,会出现:

 > g ++ test2.cc -o test2 
/home/chris/Desktop/c++/test2/.objs/main.o||函数`main':|
main.cpp :(。text + 0x22)||未定义引用`al_install_system'|
main.cpp :(。text + 0x3e)||未定义引用`al_create_display'|
main.cpp :(。text + 0x6b)||未定义引用`al_map_rgb'|
main.cpp :(。text + 0x8e)|| undefined reference to`al_clear_to_color'|
main.cpp :(。text + 0x93)||未定义引用`al_flip_display'|
main.cpp :(。text + 0xa1)||未定义引用`al_rest'|
main.cpp :(。text + 0xa9)|| undefined reference to`al_destroy_display'|
|| === Build finished:7 errors,0 warnings === |

我使用的代码:

  #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!\\\
);
return -1;
}

display = al_create_display(640,480);
if(!display){
fprintf(stderr,无法创建显示!\\\
);
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;
}

allegro-config --libs 不返回任何内容。

解决方案

您需要链接到Allegro库,

有问题的一部分。通常,您应该能够将其添加到命令行,如下所示:

  g ++`allegro-config --libs`在我的系统(Ubuntu 10.10)上,它提供了这个:

  $ allegro-config --libs 
-L ​​/ usr / lib -Wl,-Bsymbolic-functions -lalleg-4.2.2

正在调用正确的 allegro-config ?也许你应该指定它的完整路径?


I tried installing the Allegro library today. I have same experience in C++, but it seems I have none in doing stuff like that. I have compiled Allegro 5.0 from source and put it in /usr/lib/gcc/i486-linux-gnu/4.4/include/allegro5. But when I try to compile my code, this comes up:

    > g++ test2.cc -o test2
/home/chris/Desktop/c++/test2/.objs/main.o||In function `main':|
main.cpp:(.text+0x22)||undefined reference to `al_install_system'|
main.cpp:(.text+0x3e)||undefined reference to `al_create_display'|
main.cpp:(.text+0x6b)||undefined reference to `al_map_rgb'|
main.cpp:(.text+0x8e)||undefined reference to `al_clear_to_color'|
main.cpp:(.text+0x93)||undefined reference to `al_flip_display'|
main.cpp:(.text+0xa1)||undefined reference to `al_rest'|
main.cpp:(.text+0xa9)||undefined reference to `al_destroy_display'|
||=== Build finished: 7 errors, 0 warnings ===|

The code I am using:

#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;
}

allegro-config --libs returns nothing. I had Allegro as package first, but it didn'T work either.

解决方案

You need to link with the Allegro libraries, but you don't seem to do so.

There's part of your problem. Normally, you should be able to add it to your command line, like so:

g++ `allegro-config --libs` test2.cc -o test2

On my system (Ubuntu 10.10) it gives this:

$ allegro-config --libs
-L/usr/lib -Wl,-Bsymbolic-functions -lalleg-4.2.2

Are you invoking the right allegro-config? Maybe you should specify the full path to it?

这篇关于Allegro在Ubuntu中:未定义引用`al_install_system'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 01:40