directfb2 / DirectFB2

Core DirectFB library
GNU Lesser General Public License v2.1
136 stars 16 forks source link

SDL2 issue using directfb2 #90

Closed edemirkan closed 1 year ago

edemirkan commented 1 year ago

I know this may not be a question directly related to DirectFB2, but any insight is greatly appreciated. I'm cross compiling SDL2 (release-2.26.3) using the latest version of DirectFB2, again I built and installed, but only getting directfb not available when I start my SDL2 app.

Here's my output from SDL2 configuration,

...
checking for directfb.h... yes
-- dynamic libdirectfb -> libdirectfb-2.0.so.0
...

also can see directfb listed within drivers list.

...
Video drivers   : offscreen directfb(dynamic)
...

full configure log

checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking how to print strings... printf
checking for arm-linux-gcc... arm-linux-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether arm-linux-gcc accepts -g... yes
checking for arm-linux-gcc option to enable C11 features... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by arm-linux-gcc... arm-linux-ld
checking if the linker (arm-linux-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/rg35xx/bin/arm-linux-nm -B
checking the name lister (/opt/rg35xx/bin/arm-linux-nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to arm-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for arm-linux-ld option to reload object files... -r
checking for arm-linux-objdump... arm-linux-objdump
checking how to recognize dependent libraries... pass_all
checking for arm-linux-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-ar... arm-linux-ar
checking for archiver @FILE support... @
checking for arm-linux-strip... arm-linux-strip
checking for arm-linux-ranlib... arm-linux-ranlib
checking for gawk... gawk
checking command to parse /opt/rg35xx/bin/arm-linux-nm -B output from arm-linux-gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for arm-linux-mt... no
checking for mt... mt
configure: WARNING: using cross tools not prefixed with host triplet
checking if mt is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if arm-linux-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-linux-gcc option to produce PIC... -fPIC -DPIC
checking if arm-linux-gcc PIC flag -fPIC -DPIC works... yes
checking if arm-linux-gcc static flag -static works... yes
checking if arm-linux-gcc supports -c -o file.o... yes
checking if arm-linux-gcc supports -c -o file.o... (cached) yes
checking whether the arm-linux-gcc linker (arm-linux-ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for arm-linux-windres... no
checking for windres... no
checking for gawk... (cached) gawk
checking for arm-linux-gcc... (cached) arm-linux-gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether arm-linux-gcc accepts -g... (cached) yes
checking for arm-linux-gcc option to enable C11 features... (cached) none needed
checking whether the compiler supports GNU C++... yes
checking whether arm-linux-g++ accepts -g... yes
checking for arm-linux-g++ option to enable C++11 features... none needed
checking how to run the C++ preprocessor... arm-linux-g++ -E
checking for ld used by arm-linux-g++... arm-linux-ld
checking if the linker (arm-linux-ld) is GNU ld... yes
checking whether the arm-linux-g++ linker (arm-linux-ld) supports shared libraries... yes
checking for arm-linux-g++ option to produce PIC... -fPIC -DPIC
checking if arm-linux-g++ PIC flag -fPIC -DPIC works... yes
checking if arm-linux-g++ static flag -static works... yes
checking if arm-linux-g++ supports -c -o file.o... yes
checking if arm-linux-g++ supports -c -o file.o... (cached) yes
checking whether the arm-linux-g++ linker (arm-linux-ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for egrep... (cached) /usr/bin/grep -E
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for arm-linux-pkg-config... no
checking for pkg-config... /opt/rg35xx/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gsort... no
checking for sort... sort
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for GCC -MMD -MT option... yes
checking for linker option --no-undefined... yes
checking for linker option --dynamicbase... no
checking for linker option --nxcompat... no
checking for linker option --high-entropy-va... no
checking for sys/types.h... (cached) yes
checking for stdio.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for stddef.h... yes
checking for stdarg.h... yes
checking for malloc.h... yes
checking for memory.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for wchar.h... yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for limits.h... yes
checking for ctype.h... yes
checking for math.h... yes
checking for float.h... yes
checking for iconv.h... yes
checking for signal.h... yes
checking for linux/input.h... yes
checking for size_t... yes
checking how to run the C preprocessor... arm-linux-gcc -E
checking for M_PI in math.h... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for mprotect... yes
checking for malloc... yes
checking for calloc... yes
checking for realloc... yes
checking for free... yes
checking for getenv... yes
checking for setenv... yes
checking for putenv... yes
checking for unsetenv... yes
checking for bsearch... yes
checking for qsort... yes
checking for abs... yes
checking for bcopy... yes
checking for memset... yes
checking for memcmp... yes
checking for memcpy... yes
checking for memmove... yes
checking for wcslen... yes
checking for wcslcpy... no
checking for wcslcat... no
checking for _wcsdup... no
checking for wcsdup... yes
checking for wcsstr... yes
checking for wcscmp... yes
checking for wcsncmp... yes
checking for wcscasecmp... yes
checking for _wcsicmp... no
checking for wcsncasecmp... yes
checking for _wcsnicmp... no
checking for strlen... yes
checking for strlcpy... no
checking for strlcat... no
checking for _strrev... no
checking for _strupr... no
checking for _strlwr... no
checking for index... yes
checking for rindex... yes
checking for strchr... yes
checking for strrchr... yes
checking for strstr... yes
checking for strtok_r... yes
checking for itoa... no
checking for _ltoa... no
checking for _uitoa... no
checking for _ultoa... no
checking for strtod... yes
checking for strtol... yes
checking for strtoul... yes
checking for _i64toa... no
checking for _ui64toa... no
checking for strtoll... yes
checking for strtoull... yes
checking for atoi... yes
checking for atof... yes
checking for strcmp... yes
checking for strncmp... yes
checking for _stricmp... no
checking for strcasecmp... yes
checking for _strnicmp... no
checking for strncasecmp... yes
checking for strcasestr... yes
checking for vsscanf... yes
checking for vsnprintf... yes
checking for fopen64... yes
checking for fseeko... yes
checking for fseeko64... yes
checking for sigaction... yes
checking for setjmp... yes
checking for nanosleep... yes
checking for sysconf... yes
checking for sysctlbyname... no
checking for getauxval... yes
checking for elf_aux_info... no
checking for poll... yes
checking for _Exit... yes
checking for pow in -lm... yes
checking for acos... yes
checking for acosf... yes
checking for asin... yes
checking for asinf... yes
checking for atan... yes
checking for atanf... yes
checking for atan2... yes
checking for atan2f... yes
checking for ceil... yes
checking for ceilf... yes
checking for copysign... yes
checking for copysignf... yes
checking for cos... yes
checking for cosf... yes
checking for exp... yes
checking for expf... yes
checking for fabs... yes
checking for fabsf... yes
checking for floor... yes
checking for floorf... yes
checking for trunc... yes
checking for truncf... yes
checking for fmod... yes
checking for fmodf... yes
checking for log... yes
checking for logf... yes
checking for log10... yes
checking for log10f... yes
checking for lround... yes
checking for lroundf... yes
checking for pow... yes
checking for powf... yes
checking for round... yes
checking for roundf... yes
checking for scalbn... yes
checking for scalbnf... yes
checking for sin... yes
checking for sinf... yes
checking for sqrt... yes
checking for sqrtf... yes
checking for tan... yes
checking for tanf... yes
checking for iconv_open in -liconv... no
checking for iconv... yes
checking for struct sigaction.sa_sigaction... yes
checking for libunwind.h... no
checking for GCC builtin atomic operations... yes
checking for GCC -mmmx option... no
checking for GCC -m3dnow option... no
checking for GCC -msse option... no
checking for immintrin.h... no
checking for Altivec with GCC altivec.h and -maltivec option... no
checking for Altivec with GCC -maltivec option... no
checking for Altivec with GCC altivec.h and -faltivec option... no
checking for Altivec with GCC -faltivec option... no
checking for GCC -mlsx option... no
checking for lsxintrin.h... no
checking for GCC -mlasx option... no
checking for lasxintrin.h... no
checking for GCC -Wall option... yes
checking for necessary GCC -Wno-multichar option... no
checking for GCC -fno-strict-aliasing option... yes
checking for GCC -fvisibility=hidden option... yes
checking for GCC -Wdeclaration-after-statement option... yes
checking for dlfcn.h... (cached) yes
checking for dlopen in -lc... yes
checking for dlopen... yes
checking for ARM NEON... yes
checking for O_CLOEXEC... yes
checking for ALSA CFLAGS...
checking for ALSA LDFLAGS...  -lasound -lm -ldl -lpthread
checking for libasound headers version >= 1.0.11... found.
checking for snd_ctl_open in -lasound... yes
-- dynamic libasound -> libasound.so.2
checking for libpipewire-0.3 >= 0.3.20... no
checking for artsc-config... no
checking for esound >= 0.2.8... no
checking for esd-config... no
checking for ESD - version >= 0.2.8... no
checking for audio/audiolib.h... no
checking for AuOpenServer in -laudio... no
checking for NAS audio support... no
checking for samplerate.h... no
checking for bcm_host brcmegl... no
checking for Raspberry Pi 2/3... no
checking for directfb >= 1.0.0... yes
checking for directfb.h... yes
-- dynamic libdirectfb -> libdirectfb-2.0.so.0
checking for Linux 2.4 unified input interface... yes
checking for sys/inotify.h... yes
checking for inotify_init... yes
checking for inotify_init1... yes
checking for ibus-1.0... no
checking for ibus-1.0/ibus.h... no
checking for Linux kd.h... yes
checking for pthreads... yes
checking for recursive mutexes... yes
checking for pthread semaphores... yes
checking for sem_timedwait... yes
checking for pthread_np.h... no
checking for pthread_setname_np... yes
checking for pthread_set_name_np... no
checking for clock_gettime in -lrt... yes
checking for linux/version.h... yes
checking for Vivante VDK API... no
checking for Vivante FB API... no
checking whether to install sdl2-config... yes
checking for linker option --enable-new-dtags... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sdl2-config
config.status: creating sdl2-config.cmake
config.status: creating sdl2-config-version.cmake
config.status: creating SDL2.spec
config.status: creating sdl2.pc
config.status: creating include/SDL_config.h
config.status: executing libtool commands
config.status: executing sdl2_config commands
config.status: executing summary commands
SDL2 Configure Summary:
Building Shared Libraries
Enabled modules : atomic audio video render events joystick haptic filesystem threads timers file misc locale loadso cpuinfo assembly
Assembly Math   :
Audio drivers   : alsa(dynamic)
Video drivers   : offscreen directfb(dynamic)
Input drivers   : linuxev linuxkd
Enable virtual joystick APIs : NO
Using libsamplerate : NO
Using libudev       : NO
Using dbus          : NO
Using ime           : NO
Using ibus          : NO
Using fcitx         : NO

Here's my .directfbrc which is set within the $HOME for the app. All the directfb related libs are kept within the libs folder, which I set with $LD_LIBRARY_PATH.

system=fbdev
module-dir=lib/directfb-2.0-0
mode=640x480
depth=16
pixelformat=RGB16
bg-color=000000

Interestingly the same setup works for directfb 1.7.7. I also verified my complied directfb2 libs are working correctly, with the provided sample apps. It's just that SDL2 can't find the video driver.

caramelli commented 1 year ago

In your .directfbrc file, can you try commenting out the line module-dir=lib/directfb-2.0-0 or updating it with an absolute path?

caramelli commented 1 year ago

I think it should work if you add the --disable-directfb-shared option when running configure.

The failure was caused by the symbols directfb_major_version, directfb_minor_version, directfb_micro_version which are no longer defined in DirectFB2: I will restore them for compatibility with the legacy DirectFB.

edemirkan commented 1 year ago

Thanks for the reply, Nicolas. This worked when I added --disable-directfb-shared But in the meantime created a mix of old and new. I guess keeping old and new side-by-side causes them to be linked together when shared param is disabled.

~/code/github/rg35xx/rg35xx-SDL2/rg35xx$ readelf -d build/.libs/libSDL2-2.0.so.0.2600.3

Dynamic section at offset 0x1b2d60 contains 39 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libasound.so.2]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libdirectfb-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libfusion-1.7.so.7]
 0x00000001 (NEEDED)                     Shared library: [libdirect-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libfusion-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdirect-1.7.so.7]
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000e (SONAME)                     Library soname: [libSDL2-2.0.so.0]
 0x0000001d (RUNPATH)                    Library runpath: [lib/]
 0x0000000c (INIT)                       0x138b0
 0x0000000d (FINI)                       0x185a10
 0x00000019 (INIT_ARRAY)                 0x1c0e30
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0x1c0e34
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0xf4
 0x6ffffef5 (GNU_HASH)                   0x21a4
 0x00000005 (STRTAB)                     0x7d18
 0x00000006 (SYMTAB)                     0x3ae8
 0x0000000a (STRSZ)                      19191 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0x1c2eb8
 0x00000002 (PLTRELSZ)                   1424 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x13320
 0x00000011 (REL)                        0xd188
 0x00000012 (RELSZ)                      24984 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x00000018 (BIND_NOW)
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6ffffffe (VERNEED)                    0xd058
 0x6fffffff (VERNEEDNUM)                 4
 0x6ffffff0 (VERSYM)                     0xc810
 0x6ffffffa (RELCOUNT)                   3077
 0x00000000 (NULL)                       0x0
caramelli commented 1 year ago

You can check EXTRA_LDFLAGS in the SDL2 Makefile (should contain "-ldirectfb -ldirect -lfusion") and verify that you have the following symbolic links in your lib directory:

libdirectfb.so -> libdirectfb-2.0.so
libdirect.so -> libdirect-2.0.so
libfusion.so -> libfusion-2.0.so
edemirkan commented 1 year ago

Thanks again. I did something similar, and used a script to replace those symbolic links to /opt/directfb2/ where I installed directfb2. So, overall, my steps were;

  1. Build and install directfb2 to /opt/directfb2.
  2. Recreate symbolic links libdirectfb.so, libdirect.so,libfusion.so formerly pointing to v1.7.7 to their new locations in /opt/directfb2/lib/.
  3. Add directfb2's pkgconfig to PKG_CONFIG_PATH;
export PKG_CONFIG_PATH=/opt/directfb2/lib/pkgconfig/

Configure SDL2 params;

../configure --disable-joystick-virtual --disable-sensor --disable-power --disable-diskaudio --disable-video-x11 --disable-video-wayland --disable-video-kmsdrm \
            --disable-video-vulkan --disable-dbus --disable-ime --disable-fcitx --disable-hidapi --disable-pulseaudio --disable-sndio --disable-libudev \
            --disable-jack --disable-video-opengl --disable-video-opengles --disable-video-opengles2 --disable-oss --disable-dummyaudio --disable-video-dummy \
            --enable-alsa --enable-video-directfb --enable-arm-neon --disable-directfb-shared  --disable-alsa-shared \
            --host=arm-linux CFLAGS="-marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -I/opt/directfb2/include/directfb"

libSDL2 is now pointing to proper shared libraries.

~/code/github/rg35xx/rg35xx-SDL2/rg35xx$ readelf -d build/.libs/libSDL2-2.0.so.0.2600.3

Dynamic section at offset 0x1b2d80 contains 35 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libasound.so.2]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libdirectfb-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdirect-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libfusion-2.0.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000e (SONAME)                     Library soname: [libSDL2-2.0.so.0]
 0x0000001d (RUNPATH)                    Library runpath: [lib/]
 0x0000000c (INIT)                       0x13770
 0x0000000d (FINI)                       0x1858d0
 0x00000019 (INIT_ARRAY)                 0x1c0e50
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0x1c0e54
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0xf4
 0x6ffffef5 (GNU_HASH)                   0x21a4
 0x00000005 (STRTAB)                     0x7d18
 0x00000006 (SYMTAB)                     0x3ae8
 0x0000000a (STRSZ)                      18874 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0x1c2eb8
 0x00000002 (PLTRELSZ)                   1424 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x131e0
 0x00000011 (REL)                        0xd048
 0x00000012 (RELSZ)                      24984 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x00000018 (BIND_NOW)
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6ffffffe (VERNEED)                    0xcf18
 0x6fffffff (VERNEEDNUM)                 4
 0x6ffffff0 (VERSYM)                     0xc6d2
 0x6ffffffa (RELCOUNT)                   3077
 0x00000000 (NULL)                       0x0
caramelli commented 1 year ago

Using the commit https://github.com/directfb2/DirectFB2/commit/185a5fce4aeb8b581c0b42fc040c83c5a1b6943a, SDL2 should now also work without specifying the --disable-directfb-shared option when running configure. Thanks for having reported the issue!