[英]Undefined symbols for architecture x86_64 in C
Today I installed the Allegro game programming library for C and I've tried to include one of the header files but when I try to execute gcc -I./include example.c -o a.exe
in the terminal, I keep on getting this error: 今天我为C安装了Allegro游戏编程库,我试图包含其中一个头文件但是当我尝试在终端中执行
gcc -I./include example.c -o a.exe
时,我继续获取这个错误:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas? 有任何想法吗? I installed Allegro 5 using the instructions here: https://wiki.allegro.cc/index.php?title=Install_Allegro5_From_GIT/OSX
我使用以下说明安装了Allegro 5: https : //wiki.allegro.cc/index.php?title = Install_Allegro5_From_GIT / OSX
example.c code: example.c代码:
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, const char *argv[]){
puts(“Hello, world!”);
return 0;
}
You need to link your executable to Allegro . 您需要将可执行文件链接到Allegro 。
According to the FAQ, you should add -lallegro
to your compile command, or -lallegro -lallegro_main
on OSX 根据FAQ,您应该将
-lallegro
添加到您的编译命令,或者在OSX上添加-lallegro -lallegro_main
You may need other flags, and Allegro 5 uses pkg-config instead of allegro-config, so do pkg-config allegro-5.0 allegro_main-5.0 --cflags --libs
to find out. 您可能需要其他标志,Allegro 5使用pkg-config而不是allegro-config,所以
pkg-config allegro-5.0 allegro_main-5.0 --cflags --libs
要查找。
You can combine this into a compiler command by using backticks, eg 您可以使用反引号将其组合成编译器命令,例如
$CC -W -Wall `pkg-config allegro-5.0 allegro_main-5.0 --cflags --libs` foo.c -o foo.exe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.