Suy*_*ooo 2 c++ g++ allegro5 ubuntu-10.04
我今天尝试安装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||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 ===|
Run Code Online (Sandbox Code Playgroud)
我正在使用的代码:
#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;
}
Run Code Online (Sandbox Code Playgroud)
allegro-config --libs没有回报.我首先将Allegro作为包装,但它也没有用.
Mat*_*hew 21
Allegro 5使用pkg-config.
gcc foo.c -o foo $(pkg-config --libs allegro-5.0)
Run Code Online (Sandbox Code Playgroud)
您还需要指定您使用的插件库:
gcc foo.c -o foo $(pkg-config --libs allegro-5.0 allegro_image-5.0)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8399 次 |
| 最近记录: |