Zephyr include LZ4 Frame

The example for LZ4 works fine, however I want to use the frame format and not block format.

Therefore I added #include "lz4frame.h" to my main.c and tried to use LZ4F_compressFrame().

But the compiler prints undefined reference to `LZ4F_compressFrame'

The prj.conf contains CONFIG_LZ4=y


Parents
  • Small update, I got it running using the CMakeLists directly, however it crashed at LZ4F_compressFrame(), more specific in the MEM_INIT() function:


    This is my code:

    	static const unsigned char src[24] = {0x46, 0x3d, 0xff, 0xff, 0x7b, 0x62, 0xf3, 0xb0, 0x7f, 0xdc, 0xff, 0x87,
    										  0x8f, 0x63, 0x7f, 0x7e, 0x9e, 0x67, 0xbe, 0x13, 0x5c, 0xfe, 0xc0, 0xff};
    
    	const int max_dst_size = LZ4F_compressFrameBound(sizeof(src), NULL) * 2;
    
    	char *compressed_data = malloc((size_t)max_dst_size);
    
    	if (compressed_data == NULL)
    	{
    		printk("Failed to allocate memory for compressed data\n");
    
    		return 0;
    	}
    
    	const int compressed_data_size = LZ4F_compressFrame(compressed_data, max_dst_size, src, sizeof(src), NULL);
    
    	if (compressed_data_size <= 0)
    	{
    		printk("Failed to compress the data\n");
    		return 0;
    	}
    
    	printk("Original Data size: %d\n", sizeof(src));
    	printk("Compressed Data size : %d\n", compressed_data_size);

  • Hi,

    I am not sure what could be the problem here.

    One could think of buffer being Null, but that is not indicated in the snapshot.

    Can you start debugging and see if it helps.

    I can also look if you attach your minimal project as you have right now.

Reply Children
No Data
Related