Skip to content

undefined reference to `ring_buf_item_put' #30183

@jasonedn

Description

@jasonedn

Describe the bug
A clear and concise description of what the bug is.
What have you tried to diagnose or workaround this issue?

To Reproduce
Steps to reproduce the behavior:

  1. mkdir build; cd build
  2. cmake -DBOARD=board_xyz
  3. make
  4. See error

Expected behavior
When the project with ring buffer was built, it reported the following error:
undefined reference to "ring_buf_item_put"

Impact

Logs and console output
undefined reference to `ring_buf_item_put'
collect2: error: ld returned 1 exit status

Environment (please complete the following information):
OS - Windows
Toolchain: Zephyr SDK

Additional context
Add any other context about the problem here.
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#include <sys/printk.h>
#include <sys/__assert.h>
#include <string.h>
#include <sys/ring_buffer.h>

/* size of stack area used by each thread */
#define STACKSIZE 1024

/* scheduling priority used by each thread */
#define PRIORITY 7
#define RB_DATA_TYPE1 ( 0x01 )
#define RB_DATA_TYPE2 ( 0x02 )
#define RB_DATA_TYPE1_VAL ( 0x11 )
#define RB_DATA_TYPE2_VAL ( 0x22 )

RING_BUF_ITEM_DECLARE_POW2(my_ring_buf, 4);

static void producer_thread( void);

K_THREAD_DEFINE(producer_thread_id, STACKSIZE, producer_thread, NULL, NULL, NULL,
PRIORITY, 0, 0);

static void producer_thread(void)
{
int ret;
uint32_t count = 0;
uint32_t data;

while (1) {
    printk( "Producer: putting data...\n" );
    if( 0x1 & count ) {
        ret = ring_buf_item_put( &my_ring_buf, RB_DATA_TYPE1, RB_DATA_TYPE1_VAL, &count, 1 );
    } else {
        ret = ring_buf_item_put( &my_ring_buf, RB_DATA_TYPE2, RB_DATA_TYPE2_VAL, &count, 1 );
    }
    if ( 0 != ret ) {
        printk( "No memory available\r\n" );
    }
    k_msleep( 5000 );
}

}

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions