Jump to content

Cross Compile SDL2 to arm


Sting

Recommended Posts

I want to use the new SDL2 board for my build/debug environment on a beaglebone black.  I installed SDL2 on that machine and copied the arm shared object to my build machine.  I took the Makefile from the Linux-SDL directory and after making the modifications, I attempted the first build.

I get the error message:

/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: /usr/local/bin/sdl2-config: not found

sdl2-config is a shell script that tells where components have been installed.  The problem is, I can't have where they are installed on the local machine determine where they are installed on the remote machine.  Is there a way to ignore this shell script and I will tell the linker where the objects are in the lib path, or at least let me tell where the shell script is located.

Link to comment
Share on other sites

sdl-config is tool which prints CFLAGS needed by project for building and linking on host environment. It's working only for host build.

For cross compiling you have to replace sdl-config with
CFLAGS += `<platform-tripple>-pkg-config sdl2 --cflags --libs`

Or just manually add necessary flags
CFLAGS += D_THREAD_SAFE -I<bb_userland_path>/include/SDL2 -L<bb_userland>/lib -lSDL2

All paths are for local machine, do not carry about files placement on target machine, while building. Just give compiler chance to find them to build binary

On target machine only.so files needed. Usually can be located in  /usr/lib or /usr/local/lib

Edited by olegator
Link to comment
Share on other sites

I set the following:

CFLAGS += -I/usr/local/arm/sdl2/include/SDL2 -L/usr/local/arm/sdl2/lib -lSDL2

and make reports:

ray@Newton:~/projects/BTest$ make
.
C Compiler Options....
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: /usr/local/bin/sdl2-config: not found
 

Link to comment
Share on other sites

Do you actually have sdl2-config available/installed? You should be able to just type this command in your terminal (outside of any makefile) and get the corresponding paths back:

joel@ubuntu:~$ sdl2-config --libs --cflags
-L/usr/lib/i386-linux-gnu -lSDL2
-I/usr/include/SDL2 -D_REENTRANT

If that doesn't work you most likely don't have that program/script installed or the package manager of the distribution you are using didn't put it in the standard path.
In case of you missed that: You have to install the libsdl2-dev package on your host system (the system where you are compiling your µGFX program on). The sdl2-config program/script is part of that package.

Link to comment
Share on other sites

Actually, forget what I just posted above. I missed that you are trying to set the paths manually now. Sorry!

The problem is that we have the following lines in /drivers/multiple/SDL/driver.mk:

CFLAGS += `sdl2-config --cflags || /usr/local/bin/sdl2-config --cflags`
LDFLAGS += `sdl2-config --libs --cflags || /usr/local/bin/sdl2-config --libs --cflags`

Try removing those.

Link to comment
Share on other sites

I removed those lines and got the project to build.  When I deployed it to the device a window is created but it is transparent.  I will do some debugging but I suspect that there is something wrong with the library on that device.

I did some easy fprintf statements to see if it was getting past gfxInit and it isn't.  I will spend some time trying to see where it is hanging.  Thanks for all of your help getting this going.

Link to comment
Share on other sites

in case it helps, I modified the gfxconf.h file for my project to include input and mouse to see if that would make a difference.

#define GFX_USE_OS_LINUX		TRUE

/* GFX sub-systems to turn on */
#define GFX_USE_GDISP			TRUE
#define GFX_USE_INPUT           TRUE

#define GINPUT_NEED_MOUSE       TRUE

/* Features for the GDISP sub-system. */
#define GDISP_NEED_VALIDATION	TRUE
#define GDISP_NEED_CLIP			TRUE

When I built it I get:

Compiling /usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c
/usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c: In function ‘SDL_loop’:
/usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c:224:59: error: ‘GINPUT_MOUSE_BTN_LEFT’ undeclared (first use in this function)
     context->buttons = (event.type ==SDL_MOUSEBUTTONDOWN)?GINPUT_MOUSE_BTN_LEFT:0;
                                                           ^
/usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c:224:59: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c: In function ‘SDL_MouseRead’:
/usr/local/arm/ugfx/drivers/multiple/SDL/gdisp_lld_SDL.c:448:31: error: ‘GINPUT_MOUSE_BTN_LEFT’ undeclared (first use in this function)
   pt->z = (context->buttons & GINPUT_MOUSE_BTN_LEFT) ? 1 : 0;
                               ^
make: *** [.build/obj/GFXLIB/drivers/multiple/SDL/gdisp_lld_SDL.o] Error 1

 

Link to comment
Share on other sites

Here is some suggestion:

1. SDL Driver requires os preinitialization staff. So:
1.1 Check, that makefile contains: GFX_OS_PRE_INIT_FUNCTION=sdl_driver_init
1.2 Make sure, that function sdl_driver_init really called. Just add fprintf to stderr in begining of sdl_driver_init
 
I do not have beaglebone, and can't test it myself. BTW, Google find next topics:
http://forums.libsdl.org/viewtopic.php?p=43982&sid=c7877958a1b5e386fdaabcec36f6b8da
http://forums.libsdl.org/viewtopic.php?p=43940&sid=05d81b018757f5170e952f34c2e7cf2a
There are posts there, that SDL2 does not support BBB. Can't confirm or disconfirm this.
It's sad. For example SDL2 and uGFX SDL2 driver is working very well on RPI 2.

Link to comment
Share on other sites

11 hours ago, olegator said:

1. SDL Driver requires os preinitialization staff. So:
1.1 Check, that makefile contains: GFX_OS_PRE_INIT_FUNCTION=sdl_driver_init
1.2 Make sure, that function sdl_driver_init really called. Just add fprintf to stderr in begining of sdl_driver_init

I put the line in the makefile and the entire program executes.  The only slight problem is there is no output in the window.  It takes the contents of what is below the window.  I will assume that it is a SDL2 issue and attempt to build it again and see if I can make some progress.

I read the top article before and it points to how the driver was built for the rp.

just so you know, the template makefile for the linux-sdl example does not have the sdl_driver_init line.  

Thanks for all of your help.

Link to comment
Share on other sites

4 hours ago, Sting said:

just so you know, the template makefile for the linux-sdl example does not have the sdl_driver_init line.

That is because it has been added to the default values of the driver Makefile: https://git.ugfx.io/uGFX/uGFX/src/master/drivers/multiple/SDL/driver.mk#L3
The template makefile uses that driver makefile, therefore there is no need to add it there as well.

Link to comment
Share on other sites

You are correct and now I can't understand why when I added the line to my makefile the demos/module/gdisp/basics would no longer hang in the gfxInit call.  I can't use the driver, I assume because of the BBB does not support it at this point, so who knows what the problem really is.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...