[英]Undefined symbols for architecture x86_64 in C
今天我為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)
有任何想法嗎? 我使用以下說明安裝了Allegro 5: https : //wiki.allegro.cc/index.php?title = Install_Allegro5_From_GIT / OSX
example.c代碼:
#include <stdio.h>
#include <allegro5/allegro.h>
int main(int argc, const char *argv[]){
puts(“Hello, world!”);
return 0;
}
根據FAQ,您應該將-lallegro
添加到您的編譯命令,或者在OSX上添加-lallegro -lallegro_main
您可能需要其他標志,Allegro 5使用pkg-config而不是allegro-config,所以pkg-config allegro-5.0 allegro_main-5.0 --cflags --libs
要查找。
您可以使用反引號將其組合成編譯器命令,例如
$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.