0
votes

I am trying to build the uGFX library statically to my main binary. I am cross compiling. My build system is Ubuntu Linux and the host is an ARM environment. The building succeeds, but when executing the binary on my host the following message keeps bugging me:

binary_name: /lib/libc.so.6: version 'GLIBC_2.17' not found (required by binary_name)

This only occurs when including the uGFX sources to my binary. This is how my CMakeLists.txt looks like for building:

cmake_minimum_required(VERSION 3.9.1)
project(MyBinary)

set(CMAKE_C_FLAGS_DEBUG "-nostdinc -fsigned-char -Wstrict-prototypes -Wno-trigraphs -Wimplicit -Wformat")
set(CMAKE_CXX_FLAGS_DEBUG "-nostdinc++ -fsigned-char -Wno-trigraphs -Wimplicit -Wformat")

include_directories(./include
                ./include/ugfx
                ./ExternalProjects/ugfx
                ./ExternalProjects/ugfx/drivers/gdisp/framebuffer
                /usr/gnueabi/lib/gcc/arm-brcm-linux-gnueabi/6.3.0/include
                /usr/arm-linux-gnueabi/include
                /usr/arm-linux-gnueabi/include/linux)
link_directories(/usr/gnueabi/arm-brcm-linux-gnueabi/sysroot/lib)

set(SOURCE_FILES
   ./ExternalProjects/ugfx/src/gfx_mk.c
   ./ExternalProjects/ugfx/drivers/gdisp/framebuffer/gdisp_lld_framebuffer.c
   ./ExternalProjects/ugfx/drivers/ginput/touch/Linux-Event/gmouse_lld_linux_event.c
   MyBinary.c)

add_executable(MyBinary ${SOURCE_FILES})

target_link_libraries(MyBinary curl ssl)

My toolchain cmake file:

include(CMakeForceCompiler)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSROOT /usr/gnueabi/arm-brcm-linux-gnueabi/sysroot)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CROSS_COMPILER arm-linux-gnueabi)
set(CMAKE_C_COMPILER "/usr/gnueabi/bin/arm-brcm-linux-gnueabi-gcc")
set(CMAKE_CXX_COMPILER "/usr/gnueabi/bin/arm-brcm-linux-gnueabi-gcc")

When inspecting my binary with objdump I notice the following:

Version References:
  required from libc.so.6:
    0x06969197 0x00 04 GLIBC_2.17
    0x0d696914 0x00 03 GLIBC_2.4
  r equired from libpthread.so.0:
   0x0d696914 0x00 02 GLIBC_2.4

Which explains the message I get. Even further inspection with objdump -T reveals the following:

...
00000000      DF *UND*  00000000  GLIBC_2.4   abort
00000000      DF *UND*  00000000  GLIBC_2.17  clock_gettime
00000000      DF *UND*  00000000  GLIBC_2.4   system
...

I tried the linker options nodefaultlibs and nostdlib. The libc.so.6 file is available in the sysroot. I tried even to use find_library(MYLIBC c-2.25 PATHS /usr/gnueabi/arm-brcm-linux-gnueabi/sysroot/lib) in my CMakeLists.txt and include it in my target_link_libraries for the binary, but no luck there either.

How can I make sure the toolchain libc is linked against my binary?

Update 1

To answer the questions first. Yes, I've tried statically link the libc to my binary. But then somehow the binary gets too big. Well, the device crashes with a SIGSEGV. Besides, I would prefer not to statically link the clib because ultimately I want uGFX to be dynamically linked too. And statically link libc to a shared one is a no go. I can also statically link everything together, but the binary would become massive and would not be very handy for updating individual libraries in the future.

On the device the libc.so.6 exists. I managed to get a dump of the filesystem. It lives in the /lib directory of the host. Besides, the binaries I upload without uGFX work with GLIBC_2.4 and work fine dynamically linked.

The host system is running the following OS:

Linux (none) 2.6.32.9 #1 PREEMPT Tue Jan 16 11:00:00 CST 2018 armv6l GNU/Linux

Also, the above cmake files maybe unclear in respect to statically link it to the binary. The samples show the sources of uGFX being added to the binary itself. But I initially tried it with the following:

# Find libc-2.25.so in sysroot (which lives there)
find_library(MYLIBC c-2.25 PATHS /usr/gnueabi/arm-brcm-linux-gnueabi/sysroot/lib)
add_library(gfx STATIC
    ./ExternalProjects/ugfx/src/gfx_mk.c
    ./ExternalProjects/ugfx/drivers/gdisp/framebuffer/gdisp_lld_framebuffer.c
    ./ExternalProjects/ugfx/drivers/ginput/touch/Linux-Event/gmouse_lld_linux_event.c)
target_link_libraries(gfx ${MYLIBC})
target_link_libraries(MyBinary ${MYLIBC} gfx curl ssl)

Update 2

I managed to get rid of the GLIB dependency message by adding this line to the library :

asm(".symver clock_gettime,clock_gettime@");

The linking troubles are over, now it terminates with the following:

[TERMINATION] errorNum = 11 POSIX signal 11 : SIGSEGV

This looks like the same thing when I was linking everything statically. I will investigate further on this. If anyone has any ideas, I'd like to hear them :)

2
What is the target OS? It may be the links in the /lib of the target system does not include a current /lib/libc.so.6 .Strom
Try to link static libc?ravin.wang

2 Answers

1
votes

Found the solution to the problem. Turned out that I needed to add the following compiler flag: -lrt. This links the realtime extensions library which includes the clock_gettime function. So I didn't need the asm hack, which was not the solution to this problem.

As for the SIGSEGV, you need to initialise the board of uGFX yourself. Which can be found, in my case for framebuffer, in board_framebuffer.h. The function static void board_init(GDisplay *g, fbInfo *fbi) needs to be edited. In here, I mmap'd the frame buffer (/dev/fb0) and assigned it to fbi->pixels. The latter is default set to 0 which caused the SIGSEGV. The board_framebuffer.h file must be copied from ${ugfx_src}/drivers/gdisp/framebuffer/board_framebuffer_template.h to your project's include dir and renamed. Also, you can use the framebuffer board file board_framebuffer.h which resides in ${ugfx_src}/boards/base/Linux-Framebuffer/board-framebuffer.h, in this particular case.

0
votes

The library you build need dynamic library libc, but your host os does not have one. please tell us which os you are running? Does it include dynamic library libc.

  1. if it includes the libc library, make sure the right link library directory
  2. if there is no libc, is it possible to use a static library instead when build uGFX or just copy the libc.so from your toolchain directory(It should exist) to your host os lib path and then try again.