简体   繁体   English

在OSX上使用GCC编译allegro5程序时出错

[英]Error compiling allegro5 program using gcc on osx

I am trying to compile a simple allegro5 program on Mac OSX 10.12 but am getting an undefined symbols error. 我正在尝试在Mac OSX 10.12上编译一个简单的allegro5程序,但遇到未定义的符号错误。 Here is the command I ran in the terminal 这是我在终端中运行的命令

gcc main.c -o hello -I/usr/local/include/ -L/usr/local/lib -lallegro_main

And here is my code. 这是我的代码。

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

Here is the error I get 这是我得到的错误

Undefined symbols for architecture x86_64:
  "_al_clear_to_color", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_create_display", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_destroy_display", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_flip_display", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_install_system", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_map_rgb", referenced from:
      __al_mangled_main in main-b86b99.o
  "_al_rest", referenced from:
      __al_mangled_main in main-b86b99.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is it possible that I did not install allegro correctly? 我可能没有正确安装Allegro? I installed it using homebrew according to the allegro wiki instructions. 我根据allegro Wiki说明使用自制软件安装了它。 https://wiki.allegro.cc/index.php?title=Getting_Started#Mac_OS https://wiki.allegro.cc/index.php?title=Getting_Started#Mac_OS

Those are linker errors. 这些是链接器错误。 You need to link to lallegro . 您需要链接到lallegro

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM