arm linux sdl,用ARM7发板为uCLinux交叉编译SDL
4 test在/home/rockins/SDL/SDL-1.2.5/test/目录下是用来测试SDL的一些测试例程。本文选择的测试例程是testver.c,其源代码如下所示:/* Test program to compare the compile-time version of SDL with the linkedversion of SDL*/#include#include "SDL.
4 test
在/home/rockins/SDL/SDL-1.2.5/test/目录下是用来测试SDL的一些测试例程。本文选择的测试例程是testver.c,其源代码如下所示:
/* Test program to compare the compile-time version of SDL with the linked
version of SDL
*/
#include
#include "SDL.h"
#include "SDL_byteorder.h"
int main(int argc, char *argv[])
{
SDL_version compiled;
/* Initialize SDL */
if ( SDL_Init(0) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(1);
}
#ifdef DEBUG
fprintf(stderr, "SDL initialized\n");
#endif
#if SDL_VERSION_ATLEAST(1, 2, 0)
printf("Compiled with SDL 1.2 or newer\n");
#else
printf("Compiled with SDL older than 1.2\n");
#endif
SDL_VERSION(&compiled);
printf("Compiled version: %d.%d.%d\n",
compiled.major, compiled.minor, compiled.patch);
printf("Linked version: %d.%d.%d\n",
SDL_Linked_Version()->major,
SDL_Linked_Version()->minor,
SDL_Linked_Version()->patch);
printf("This is a %s endian machine.\n",
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
SDL_Quit();
return(0);
}
采用下列命令编译此程序:
arm-elf-gcc -o testver testver.c -I/home/rockins/SDL/SDL-1.2.5/uclinux-build/include/SDL/ -L/home/rockins/SDL/SDL-1.2.5/uclinux-build/lib/ -elf2flt –lSDL
特别需要注意的是:在编译此程序时一定要加上-elf2flt选项,否则会出现如下错误:
undefined reference to `__CTOR_LIST__'
undefined reference to `__DTOR_LIST__'
实际上,不只是编译testver.c程序时要这样,编译其它运行在uCLinux平台上的程序时,都要加上这个选项,否则就会出现上述错误。原因简述如下:通常,在libgcc.a中是有__CTOR_LIST__和__DTOR_LIST__这两个符号的。然而,在uCLinux的toolchain中,由于某种目的,这两个符号被删掉了,因此直接编译时就会出现找不到符号引用的错误。所幸的是,在elf2flt的link script中提供了这样两个符号。因此,在采用uCLinux工具链编译可执行程序的时候,一定要加上-elf2flt选项。
言归正传,在编译好了testver程序之后,通过ftp或者nfs或者诸如此类的手段将其下载到开发板上,执行之,你将看到程序打印出SDL编译时和执行时采用的版本信息。这表明你的SDL静态链接库已经编译成功了。
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)