Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4028755
  • 博文数量: 366
  • 博客积分: 9916
  • 博客等级: 中将
  • 技术积分: 7195
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-29 23:27
个人简介

简单!

文章分类

全部博文(366)

文章存档

2013年(51)

2012年(269)

2011年(46)

分类: LINUX

2013-01-12 01:30:19

       SDL的头文件一般在/usr/include/SDL里面(跟具体的安装路径有关),输入以下指令查找相关的同文件。

  1. $ find /usr/include -name SDL*.h
  2. /usr/include/SDL/SDL_keysym.h
  3. /usr/include/SDL/SDL_types.h
  4. /usr/include/SDL/SDL_mouse.h
  5. /usr/include/SDL/SDL_rwops.h
  6. /usr/include/SDL/SDL_opengl.h
  7. /usr/include/SDL/SDL_stdinc.h
  8. /usr/include/SDL/SDL_config.h
  9. /usr/include/SDL/SDL_keyboard.h
  10. /usr/include/SDL/SDL_platform.h
  11. /usr/include/SDL/SDL_name.h
  12. /usr/include/SDL/SDL_version.h
  13. /usr/include/SDL/SDL_cdrom.h
  14. /usr/include/SDL/SDL_joystick.h
  15. /usr/include/SDL/SDL_byteorder.h
  16. /usr/include/SDL/SDL.h
  17. /usr/include/SDL/SDL_timer.h
  18. /usr/include/SDL/SDL_audio.h
  19. /usr/include/SDL/SDL_error.h
  20. /usr/include/SDL/SDL_video.h
  21. /usr/include/SDL/SDL_active.h
  22. /usr/include/SDL/SDL_getenv.h
  23. /usr/include/SDL/SDL_ttf.h
  24. /usr/include/SDL/SDL_quit.h
  25. /usr/include/SDL/SDL_mixer.h
  26. /usr/include/SDL/SDL_mutex.h
  27. /usr/include/SDL/SDL_events.h
  28. /usr/include/SDL/SDL_cpuinfo.h
  29. /usr/include/SDL/SDL_thread.h
  30. /usr/include/SDL/SDL_main.h
  31. /usr/include/SDL/SDL_syswm.h
  32. /usr/include/SDL/SDL_image.h
  33. /usr/include/SDL/SDL_loadso.h
  34. /usr/include/SDL/SDL_endian.h

      查看so文件输入以下指令:

  1. $ find /usr/lib -name libSDL*
    /usr/lib/i386-linux-gnu/libSDL_mixer-1.2.so.0
    /usr/lib/i386-linux-gnu/libSDL_ttf.a
    /usr/lib/i386-linux-gnu/libSDL_image-1.2.so.0
    /usr/lib/i386-linux-gnu/libSDL_image.so
    /usr/lib/i386-linux-gnu/libSDL_image-1.2.so.0.8.4
    /usr/lib/i386-linux-gnu/libSDLmain.a
    /usr/lib/i386-linux-gnu/libSDL_image.a
    /usr/lib/i386-linux-gnu/libSDL_ttf-2.0.so.0.10.1
    /usr/lib/i386-linux-gnu/libSDL_ttf.so
    /usr/lib/i386-linux-gnu/libSDL-1.2.so.0.11.4
    /usr/lib/i386-linux-gnu/libSDL_mixer-1.2.so.0.12.0
    /usr/lib/i386-linux-gnu/libSDL_mixer.so
    /usr/lib/i386-linux-gnu/libSDL-1.2.so.0
    /usr/lib/i386-linux-gnu/libSDL_ttf-2.0.so.0
    /usr/lib/i386-linux-gnu/libSDL_mixer.a
    /usr/lib/i386-linux-gnu/libSDL.so
    /usr/lib/i386-linux-gnu/libSDL.a
    /usr/lib/libSDLmain.a
    /usr/lib/libSDL.la
    /usr/lib/libSDL-1.2.so.0.11.4
    /usr/lib/libSDL-1.2.so.0
    /usr/lib/libSDLmain.la
    /usr/lib/libSDL.so
    /usr/lib/libSDL.a
编译的时候,只需要加上“-I  /usr/include/SDL   -L  /usr/libSDL”就可以了。
以上参数可以用如下指令生成:
  1. `sdl-config --cflags`
  2. `sdl-config --libs`
sdl-config是一个shell脚本,可以通过which sdl-config找到其位置,然后查看其内容。

  1. $ which sdl-config
  2. /usr/bin/sdl-config
  3. $ cat /usr/bin/sdl-config
  4. #!/bin/sh

  5. prefix=/usr
  6. exec_prefix=${prefix}
  7. exec_prefix_set=no
  8. libdir=${exec_prefix}/lib

  9. #usage="\
  10. #Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs]"
  11. usage="\
  12. Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]"

  13. if test $# -eq 0; then
  14.       echo "${usage}" 1>&2
  15.       exit 1
  16. fi

  17. while test $# -gt 0; do
  18.   case "$1" in
  19.   -*=*) optarg=`echo "$1" | LC_ALL="C" sed 's/[-_a-zA-Z0-9]*=//'` ;;
  20.   *) optarg= ;;
  21.   esac

  22.   case $1 in
  23.     --prefix=*)
  24.       prefix=$optarg
  25.       if test $exec_prefix_set = no ; then
  26.         exec_prefix=$optarg
  27.       fi
  28.       ;;
  29.     --prefix)
  30.       echo $prefix
  31.       ;;
  32.     --exec-prefix=*)
  33.       exec_prefix=$optarg
  34.       exec_prefix_set=yes
  35.       ;;
  36.     --exec-prefix)
  37.       echo $exec_prefix
  38.       ;;
  39.     --version)
  40.       echo 1.2.15
  41.       ;;
  42.     --cflags)
  43.       echo -I${prefix}/include/SDL -D_REENTRANT
  44.       ;;
  45.     --libs)
  46.       echo -L${exec_prefix}/lib -Wl,-rpath,${libdir} -lSDL -lpthread
  47.       ;;
  48.     --static-libs)
  49. # --libs|--static-libs)
  50.       echo -L${exec_prefix}/lib -Wl,-rpath,${libdir} -lSDL -lpthread -lm -ldl -lpthread
  51.       ;;
  52.     *)
  53.       echo "${usage}" 1>&2
  54.       exit 1
  55.       ;;
  56.   esac
  57.   shift
  58. done

如果还用到其它lib,如libSDL_image.so, 则还要加上“ -L  /usr/lib/SDL_image”。

下面是一个Makefile示例:
  1. CC = g++
  2. LD = g++
  3. CFLAGS = `sdl-config --cflags`
  4. LDFLAGS = `sdl-config --libs` -lSDL_image
  5. RM = /bin/rm -f
  6. OBJS = test.o
  7. PROG = test
  8. VERS = 0.1.0

  9. .PHONY: clean distclean
  10. all: $(PROG)
  11. $(PROG): $(OBJS)
  12.     $(LD) $(LDFLAGS) -s -o $(PROG) $(OBJS)
  13. test.o: test.cpp
  14.     $(CC) $(CFLAGS) -O2 -c test.cpp
  15. clean:
  16.     $(RM) *~ $(OBJS) $(PROG)
  17. .PHONY: clean



阅读(2041) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~