Thanks for the help.
We have located the problem, and it is uclibc.

uclibc does not call the contructors, but glibc does.  We wrote a simple
test program (below) to test the functionality.

#include <stdio.h>

__attribute__((constructor)) int foo()
{
        printf("hello, i am foo\n");
        return 0;
}
int main()
{
        printf("hello world\n");
        return 0;
}


Doing it with glibc (arm-linux-gcc) results in:
hello, i am foo
hello world

But (arm-uclibc-gcc) results in:
hello world


So, the problem has nothing to do with directfb, but our attempt to make
it smaller <grrr>.  I assume that this "dietlib" I've seen referenced
has been shown to work with constructors (and directfb, png, jpeg,
freetype, etc.) when doing static builds?

BTW, in the "dfb_static_build_example", the systems section may have an
issue, in that it only sets 
SYSTEMS="Wl,-udirectfb_fbdev" and not "Wl,-udirectfb_fbdev
-ldirectfb_fbdev"

Thanks!
David



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Denis Oliver
Kropp
Sent: Wednesday, June 09, 2004 3:19 AM
To: David C. Jedynak
Cc: [EMAIL PROTECTED]
Subject: [directfb-users] Re: Problems with static build


Quoting David C. Jedynak:
> I am trying to compile an app static after getting it to run
> successfully dynamic.  I am getting the "no system found" error, as
> noted in other posts.

That's because the "fbdev" (or "sdl") system wasn't linked into the
executable.

> I have tried using the "directfb-config" program as well as portions
of
> the "dfb_static_build_example" to constuct the makefile.
> 
> First of all, I am bewildered as to the usage of "-u" to the linker -
> why are we "undefining" these symbols?

The module system of DirectFB uses so called "constructor" functions.
Each module has one constructor that is called before main() gets
entered
in case of a static binary. Dynamic linking causes the constructor to be
called during dlopen(). The declaration looks like this:

#define DFB_CORE_SYSTEM(shortname)                          \
__attribute__((constructor)) void directfb_##shortname();   \
                                                            \
void                                                        \
directfb_##shortname()                                      \
{                                                           \
     direct_modules_register( &dfb_core_systems,            \
                              DFB_CORE_SYSTEM_ABI_VERSION,  \
                              #shortname, &system_funcs );  \
}

The problem with static linking is that it strips out any unreferenced
symbols.
Though the constructor functions are not referenced, they are required
to stay
in the executable. Therefore we have to "mark" these functions using
"-u".

> Also, are there any known issues with uclibc?

The uclibc is required to support "constructor" functions which are put
into
the ".ctors" section. I don't know exactly how and by whom they get
called.

> BTW, The app is single application core, so fusion should not be
needed
> at all, correct?

Yes.

> Based on other user experience, how small could this app get built
> static (not glibc) my main program .o is only 56KB.

It heavily depends on the image providers and fonts you are using,
because libz, libpng, libjpeg and libfreetype are quite big.

Without any other libraries, but with one graphics driver and two or
three input drivers, you should get an executable around 200k-300k.

> LIBDIRECTFB=-L/usr/local/arm-linux-uclibc/lib -Wl,-udirectfb
-ldirectfb
> 
> DIRECTFBSYS=-L/usr/local/arm-linux-uclibc/lib/directfb-0.9.20/systems
> -Wl,-udirectfb_fbdev

You are missing -ldirectfb_fbdev here.

Recent CVS versions also require:

-L/usr/local/arm-linux-uclibc/lib/directfb-0.9.20/wm
-Wl,-udirectfbwm_default -ldirectfbwm_default

>
DIRECTFBGFX=-L/usr/local/arm-linux-uclibc/lib/directfb-0.9.20/gfxdrivers
> -ldirectfb_epson -Wl,-udirectfb_epson
>
DIRECTFBFT2=-L/usr/local/arm-linux-uclibc/lib/directfb-0.9.20/interfaces
> /IDirectFBFont -lidirectfbfont_ft2 -Wl,-uIDirectFBFont_FT2 -lfreetype
>
DIRECTFBIMG=-L/usr/local/arm-linux-uclibc/lib/directfb-0.9.20/interfaces
> /IDirectFBImageProvider -lidirectfbimageprovider_jpeg
> -Wl,-uIDirectFBImageProvider_JPEG -ljpeg -lidirectfbimageprovider_png
> -Wl,-uIDirectFBImageProvider_PNG -lpng -lz -lm
> 
> DIRECTFBLIB=-L/usr/local/arm-linux-uclibc/lib -ldirectfb -lpthread
> 
> 
> DFB = $(DFBCONF) --graphics=epson --font=ft2 --imageprovider=jpeg,png 

You won't need this line if you specify everything yourself like above.
Also, this call is missing the "--libs" argument that includes the wm
and system module IIRC.

-- 
Best regards,
  Denis Oliver Kropp

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"

                            Convergence GmbH




Reply via email to