我尝试建立这个SDL2示例程序,但失败了。
我用 Makefile 做了它:
CFLAGS = -I/usr/include
CC = arm-linux-g++
sdltest: sdl2-test.cpp
$(CC) sdl2-test.cpp -L/usr/lib/x86_64-linux-gnu -lSDL2 -lSDL2_image $(CFLAGS) `sdl2-config --cflags --libs` -o sdl2-test
clean:
rm sdl2-test
我做到了并得到了以下结果:
$ arm-linux-g++ sdl2-test.cpp -L/usr/lib/x86_64-linux-gnu -lSDL2 -lSDL2_image -I/usr/include `sdl2-config --cflags --libs` -o sdl2-test
In file included from /usr/include/SDL2/SDL_stdinc.h:31:0,
from /usr/include/SDL2/SDL_main.h:25,
from /usr/include/SDL2/SDL.h:32,
from sdl2-test.cpp:2:
/usr/include/SDL2/SDL_config.h:4:35: fatal error: SDL2/_real_SDL_config.h: No such file or directory
#include <SDL2/_real_SDL_config.h>
^
compilation terminated.
make: *** [Makefile:4: sdltest] Error 1
然后我将CFLAGS
Makefile 更改为
CFLAGS = -I/usr/include -I/usr/include/x86_64-linux-gnu
成功了然后我得到了这样的回应
$ arm-linux-g++ sdl2-test.cpp -L/usr/lib/x86_64-linux-gnu -lSDL2 -lSDL2_image -I/usr/include -I/usr/include/x86_64-linux-gnu `sdl2-config --cflags --libs` -o sdl2-test
In file included from /usr/include/SDL2/SDL.h:38:0,
from sdl2-test.cpp:2:
/usr/include/SDL2/SDL_cpuinfo.h:102:23: fatal error: immintrin.h: No such file or directory
#include <immintrin.h>
^
compilation terminated.
make: *** [Makefile:4: sdltest] Error 1
immintrin.h
我在下面找不到/usr/include
。
我可以做什么来构建这样的示例程序?
PS:我在安装SDL2之前错误地安装了SDL1,因为我是新人,对SDL了解不够。下面是我的安装:
~/prebuilts/gcc-x64/m1/sdl/sdl2-sample$ ll /usr/include/SDL* -d
drwxr-xr-x 2 root root 4096 三 13 16:37 /usr/include/SDL/
drwxr-xr-x 2 root root 4096 三 13 13:56 /usr/include/SDL2/
~/prebuilts/gcc-x64/m1/sdl/sdl2-sample$ ll /usr/include/x86_64-linux-gnu/ -d
drwxr-xr-x 11 root root 4096 三 13 16:37 /usr/include/x86_64-linux-gnu//
~/prebuilts/gcc-x64/m1/sdl/sdl2-sample$ ll /usr/include/x86_64-linux-gnu/SDL* -d
drwxr-xr-x 2 root root 4096 三 13 10:14 /usr/include/x86_64-linux-gnu/SDL2/