我已经用教程和gcc编译字符串测试了SDL2代码的多个实例,一切都很好,但当我开始尝试使用该库时,我的M1 mac开始出现奇怪的错误。
以下是错误:
enceladus:doomengine$ gcc hello.c -o prog -lSDL2 -ldl
Undefined symbols for architecture arm64:
"_SDL_SetVideoMode", referenced from:
_main in hello-5bdcd2.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
好的,删除了所有代码,只使用了一个小示例:
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* Define window size */
#define W 608
#define H 480
static SDL_Surface* surface = NULL;
int main(int argc, char **argv)
{
surface = SDL_SetVideoMode(W, H, 32, 0);
SDL_Quit();
return 0;
}