参考:http://blog.csdn.net/banyao2006/archive/2011/01/10/6126247.aspx
环境:
- Cygwin 1.7
- Android NDK:android-ndk-r4b-windows
- SDL:1.2.14
1.下载SDL 1.2.14,将其解压到ndk的samples目录,并将文件夹改为SDL。
那么源码的位置是:/home/Administrator/android-ndk-r4b-windows/android-ndk-r4b/samples/SDL
2 .修改SDL中的Makefile.minimal,内容如下:
由于Android的framebuffer设备是 /dev/graphics/fb0 (Linux是 /dev/fb0),所以我们需要修改 ./src/video/fbcon/SDL_fbvideo.c。
将文件中所有的/dev/fb0全都替换成/dev/graphics/fb0
5.进行编译
在 Cygwin下進入SDL的根目录,执行:
make -f Makefile.minimal
编译成功之后,会产生libSDL.a
编译中可能遇到的问题:
1. compiler认为SDL_dummy_enum的size不合法:
2.重新make的时候,可能会有问题,最好先clean,然后make
3.修改文件之后,要转换成unix格式,要注意换行和空格符'\'。
环境:
- Cygwin 1.7
- Android NDK:android-ndk-r4b-windows
- SDL:1.2.14
1.下载SDL 1.2.14,将其解压到ndk的samples目录,并将文件夹改为SDL。
那么源码的位置是:/home/Administrator/android-ndk-r4b-windows/android-ndk-r4b/samples/SDL
2 .修改SDL中的Makefile.minimal,内容如下:
# Makefile to build the SDL library3.修改SDL/include/SDL_config_minimal.h,内容如下:
PREBUILT = /home/Administrator/android-ndk-r4b-windows/android-ndk-r4b/build/prebuilt/windows/arm-eabi-4.4.0
INCLUDE = -I./include -I/home/Administrator/android-ndk-r4b-windows/android-ndk-r4b/build/platforms/android-8/arch-arm/usr/include -I/usr/include
CFLAGS = -g -O2 $(INCLUDE)
CC = $(PREBUILT)/bin/arm-eabi-gcc
AR = $(PREBUILT)/bin/arm-eabi-ar
RANLIB = $(PREBUILT)/bin/arm-eabi-ranlib
CONFIG_H = include/SDL_config.h
TARGET = libSDL.a
SOURCES = src/*.c src/audio/*.c src/cdrom/*.c src/cpuinfo/*.c src/events/*.c src/file/*.c src/joystick/*.c src/stdlib/*.c src/thread/*.c src/timer/*.c src/video/*.c src/audio/dsp/*.c src/audio/dma/*.c src/video/fbcon/*.c src/joystick/dummy/*.c src/cdrom/dummy/*.c src/thread/generic/*.c src/timer/unix/*.c src/loadso/dummy/*.c \
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
all: $(TARGET)
$(TARGET): $(CONFIG_H) $(OBJECTS)
$(AR) crv $@ $^
$(RANLIB) $@
$(CONFIG_H):
cp $(CONFIG_H).default $(CONFIG_H)
clean:
rm -f $(TARGET) $(OBJECTS)
#ifndef _SDL_config_minimal_h4.修改 SDL_fbvideo.c
#define _SDL_config_minimal_h
#include "SDL_platform.h"
/* This is the minimal configuration that can be used to build SDL */
#include <stdarg.h>
/*
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned int size_t;
typedef unsigned long uintptr_t;
*/
#define SDL_AUDIO_DRIVER_OSS 1
#define SDL_CDROM_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1
#define SDL_LOADSO_DISABLED 1
#define SDL_THREADS_DISABLED 1
#define SDL_TIMER_UNIX 1
#define SDL_VIDEO_DRIVER_FBCON 1
#define HAVE_STDIO_H 1
#endif /* _SDL_config_minimal_h */
由于Android的framebuffer设备是 /dev/graphics/fb0 (Linux是 /dev/fb0),所以我们需要修改 ./src/video/fbcon/SDL_fbvideo.c。
将文件中所有的/dev/fb0全都替换成/dev/graphics/fb0
5.进行编译
在 Cygwin下進入SDL的根目录,执行:
make -f Makefile.minimal
编译成功之后,会产生libSDL.a
编译中可能遇到的问题:
1. compiler认为SDL_dummy_enum的size不合法:
./include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_enum' is negative解决办法:將SDL_stdinc.h的151行注释掉:
//SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
2.重新make的时候,可能会有问题,最好先clean,然后make
3.修改文件之后,要转换成unix格式,要注意换行和空格符'\'。