2008-04-16 11:01:07     Compiling SDL

Document created by Aaronwu Employee on Aug 6, 2013
Version 1Show Document
  • View in full screen mode

2008-04-16 11:01:07     Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54347    Hi,

 

I am having problems when it comes to the compilation of my SDL code. I can't seem to find any detail on the process needed to cross compile SDL for the BF548-EZ kit. I tried reading through the makefiles for the sdl-examples provided in the new kernel but I am finding them very hard to understand. This is due to my limited knowledge of makefiles.

 

So far when I have been compiling code for my blackfin I have just been using the following command

"bfin-uclinux-gcc -Wl,-elf2flt mycode.c -o mycode"

 

This obviously does not work with the SDL code.

 

I have compiled my SDL code using the command

"gcc -lSDL sdl.c -o sdl"

 

But when I port this to the board it does not work which I know is due to the fact that I have not crossed compiled it for the blackfin. I also know that I have to use bfin-linux-uclibc-gcc to compile the SDL but after that I am confused.

 

Is there any standard makefile or command used to compile SDL for the BF548 EZ KIT?

Also would anyone recommend using an IDE like Eclipse for the compilation of c code for the blackfin?

 

I am using CoLinux as my development host

 

Regards,

Pat

QuoteReplyEditDelete

 

 

2008-04-16 11:19:13     Re: Compiling SDL

Mike Frysinger (UNITED STATES)

Message: 54351    SDL is already cross-compiled for you in the dist, so you dont need to do that step

 

the standard way on your host to get SDL libs/cflags is not to just use "-lSDL", but to use the sdl-config wrapper script.  so you shouldnt be doing:

gcc -lSDL sdl.c -o sdl

you should actually be doing:

gcc $(sdl-config --cflags) sdl.c -o sdl $(sdl-config --libs)

 

you then extend this for the cross-compiled SDL with the staging directory.  in the top level tools/ directory, a symlink will be created for you which you can then use:

bfin-uclinux-gcc $(./tools/bfin-uclinux-sdl-config --cflags) -elf2flt sdl.c -o sdl $(./tools/bfin-uclinux-sdl-config --libs)

QuoteReplyEditDelete

 

 

2008-04-16 11:40:34     Re: Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54352    Mike:

 

When I run the last command I get  /tools/bfin-uclinux-sdl-config: no such file or directory.

QuoteReplyEditDelete

 

 

2008-04-16 11:52:17     Re: Compiling SDL

Mike Frysinger (UNITED STATES)

Message: 54354    did you build SDL in the dist ?

QuoteReplyEditDelete

 

 

2008-04-17 05:12:31     Re: Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54400    Mike:

 

I have compiled all the SDL libraries and can successfully compile the sdl-examples in the dist.

 

I also have all the header SDL header files in "root/usr/include/SDL"

 

My sdl.c file #includes are pointed to this directory too. e.g

#include /usr/include/SDL/SDL.h

QuoteReplyEditDelete

 

 

2008-04-17 08:40:41     Re: Compiling SDL

Robin Getz (UNITED STATES)

Message: 54413    Patrick:

 

Look to see how the other example applications do it.

 

It should be - from user/blkfin-apps/sdl-examples/water-1.0/water.c

#include "SDL.h"

 

You should be using sdl-config on your host as well (so it gives you the right paths for where SDL is set up). on my host it gives me:

 

rgetz@imhotep:~> sdl-config --cflags

-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

 

As Mike indicated - If you can compile it on x86 without doing something like:

gcc $(sdl-config --cflags) sdl.c -o sdl $(sdl-config --libs)

 

you are doing it wrong.

 

-Robin

QuoteReplyEditDelete

 

 

2008-04-17 09:22:24     Re: Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54414    Robin:

 

I get the same output as you do for the  sdl-config --cflags.

-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

 

 

Also when i run the command

gcc $(sdl-config --cflags) sdl.c -o sdl $(sdl-config --libs)

it compiles the sdl.c file.

 

it is the next step that Mike describes is where i am going wrong. i.e

bfin-uclinux-gcc $(./tools/bfin-uclinux-sdl-config --cflags) -elf2flt sdl.c -o sdl $(./tools/bfin-uclinux-sdl-config --libs)

when i enter the "uclinux-dist/tools" directory there is no file "bfin-uclinux-sdl-config"

 

I am trying to compile my code in the root directory so i have to point to sdl.h using my  #includes. if i just use "#include SDL.h " it cannot find the header file

QuoteReplyEditDelete

 

 

2008-04-17 09:54:11     Re: Compiling SDL

Robin Getz (UNITED STATES)

Message: 54416    Patrick:

 

I think the ./tools/ dir was just a suggestion - you can look for the exact location with something like:

 

rgetz@imhotep:~> find ./ -name "*sdl-config"

 

or peek into one of the existing Makefiles:

 

user/blkfin-apps/sdl-examples/Makefile

SDL_CONFIG=$(STAGEDIR)/usr/bin/sdl-config

 

it should be in your staging directory.

 

rgetz@imhotep:~/blackfin/releases/2008R1/uClinux-dist> ./staging/usr/bin/sdl-config --cflags

-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

 

Or look at:

http://docs.blackfin.uclinux.org/doku.php?id=existing_libraries

QuoteReplyEditDelete

 

 

2008-04-17 10:09:19     Re: Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54418    OK I think i get it now.

 

the command i am now using is:

"bfin-uclinux-gcc $(/uClinux-dist-2008R1-RC8/staging/usr/bin/sdl-config --cflags) -elf2flt sdl.c -o sdl $(./uClinux-dist-2008R1-RC8/staging/usr/bin/sdl-config --libs)"

 

I also changed the #include to #include "SDL.h".

 

I'm still getting 1 error however:

"uClinux-dist-2008R1-RC8/staging/usr/lib/libSDL.so: could not read symbols: File in wrong format"

 

Any advice on this?

QuoteReplyEditDelete

 

 

2008-04-17 10:35:26     Re: Compiling SDL

Robin Getz (UNITED STATES)

Message: 54420    Patrick:

 

You are mixing elf (fdpic) and flat file formats. you need to be using the bfin-linux-uclibc compiler.

 

If you have things selected as flat - in the top level dist - do a "make clean"

 

do a "make config_menuconfig"

 

in "Blackfin build Options" select "(FDPIC) Binary format"

 

then "make"

 

and then re-build your application with the bfin-linux-uclibc compiler (and leave out the -elf2flt flag).

 

 

 

-Robin

QuoteReplyEditDelete

 

 

2008-04-17 11:45:54     Re: Compiling SDL

Patrick Mc Donnell (IRELAND)

Message: 54425    Robin:

 

I had already set (FDPIC) Binary format.

 

When I built my application with the bfin-linux-uclibc compiler and left out the -elf2flt flag it worked.

 

Thanks for all the help,

Pat

QuoteReplyEditDelete

 

 

2008-04-17 14:20:21     Re: Compiling SDL

Mike Frysinger (UNITED STATES)

Message: 54427    sorry, i forgot that the setup of symlinks in tools/ only happens in svn trunk.  for the 2008R1 branch, you'll need to use the sdl-config script as found in the staging directory as Robin indicated.

Attachments

    Outcomes