gpt4 book ai didi

c++ - 在 OSX 上安装 SDL

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:30 26 4
gpt4 key购买 nike

我下载了 SDL2-2.0.3。我运行了 ./configure && make && make install

我也尝试过 brew install SDL2

这是我的main.c

//Using SDL and standard IO
#include <SDL2/SDL.h>
#include <stdio.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main( int argc, char* args[] ) {
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;

if (SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
}

当我运行它时

~:.make main
gcc main.c -o main
Undefined symbols for architecture x86_64:
"_SDL_GetError", referenced from:
_main in main-d5699d.o
"_SDL_Init", referenced from:
_main in main-d5699d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1
~:.

如何安装?

最佳答案

您未能链接到 libSDL2.{a,dylib}

你想要:

gcc -o main main.c -lSDL2

或者也许:

gcc -o main main.c -L/usr/local/lib -lSDL2

关于c++ - 在 OSX 上安装 SDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33225603/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com