Hi ,How to add the cross compiled zlib library to my project

I wants to add a zlib library for compression and decompression a stream of data.I was cross compiled the zlib  and generate the libz.so and libz.a file.

Parents
  • Hi,

    There is already support for compression and decompression in nRF Connect SDK through the LZ4 library. If you are free to choose compression algorithm then this library is definitely the recommendation. See the LZ4 sample found at <sdk folder>\zephyr\samples\compression\lz4\ for reference.

    For building and including precompiled (external static) libraries, please have a look at the External Library sample found at <sdk folder>\zephyr\samples\application_development\external_lib\ for reference.

    Regards,
    Terje

Reply
  • Hi,

    There is already support for compression and decompression in nRF Connect SDK through the LZ4 library. If you are free to choose compression algorithm then this library is definitely the recommendation. See the LZ4 sample found at <sdk folder>\zephyr\samples\compression\lz4\ for reference.

    For building and including precompiled (external static) libraries, please have a look at the External Library sample found at <sdk folder>\zephyr\samples\application_development\external_lib\ for reference.

    Regards,
    Terje

Children
  • In lz4  compression method the compression ration was lesser compare to zlib so we want zlib method.Here i am cross compiled zlib with arm-none-eabi toolchain and generated the shared object file(.so) .I added the .so file in external libaray like

    And my project folder looks like this:

    ├--- CMakeLists.txt

    ├--- prj.conf

    ├--- src

        â””-- main.c

    â””--- externlib

        â””-- inc

            â””--zlib.h and zconf.h #header file to be included

        â””-- lib

            â””-- libz.a  #library to be added

            â””-- libz.so #library to be added

    While i am adding my library in cmakelist i got some error like this

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    Building hello_world
    /bin/sh -c west build --build-dir /home/mysticp0004/Desktop/Linux_Study/hello_world/build /home/mysticp0004/Desktop/Linux_Study/hello_world
    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: /home/mysticp0004/Desktop/Linux_Study/hello_world
    -- CMake version: 3.20.5
    -- Cache files will be written to: /home/mysticp0004/.cache/zephyr
    -- Zephyr version: 3.3.99 (/home/mysticp0004/NCS/v2.4.0/zephyr)
    -- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
    -- Board: nrf52840dongle_nrf52840
    -- Found host-tools: zephyr 0.16.0 (/home/mysticp0004/NCS/toolchains/1f9b40e71a/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.0 (/home/mysticp0004/NCS/toolchains/1f9b40e71a/opt/zephyr-sdk)
    -- Found BOARD.dts: /home/mysticp0004/NCS/v2.4.0/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840.dts
    -- Generated zephyr.dts: /home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/dts.cmake
    Parsing /home/mysticp0004/NCS/v2.4.0/zephyr/Kconfig
    Loaded configuration '/home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/.config'
    No change to configuration in '/home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/.config'
    No change to Kconfig header in '/home/mysticp0004/Desktop/Linux_Study/hello_world/build/zephyr/include/generated/autoconf.h'
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • my cmakelist was looks like this.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    cmake_minimum_required(VERSION 3.20.0)
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(hello_world)
    target_sources(app PRIVATE src/main.c)
    set(CMAKE_PREFIX_PATH "externlib")
    find_package(ZLIB REQUIRED)
    include_directories(${ZLIB_INCLUDE_DIRS})
    set(ZLIB_LIBRARY "externlib/lib/libz.a")
    set(ZLIB_INCLUDE_DIR "externlib/include")
    target_link_libraries(app PRIVATE ${ZLIB_LIBRARIES})
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX