MIX C and CPP error undefined reference to xxx

One,Problem introduction

use nxp GUI-guider generated C lvgl code,pio have some cpp code。

1/6,project tree

├─.pio (no show,because too long)
├─.vscode
├─include
├─lib
│  └─BLTGUI
│      ├─custom
│      └─generated
│          ├─guider_customer_fonts
│          ├─guider_fonts
│          └─images
└─src

2/6,project pic

3/6,library.json

{
    "name": "BLTGUI",
    "keywords": "bltgui",
    "description": "bltgui des",
    "version": "1.0",
    "authors": {
      "name": "bobo21"
    },
    "frameworks": "arduino",
    "platforms": "espressif32",
    "build" : {
      "unflags": "-std=gnu++11",
      "flags": [
        "-I custom",
        "-I generated",
        "-I generated/guider_customer_fonts",
        "-I generated/guider_fonts",
        "-I generated/images"
      ],
      "srcFilter": [
        "+<*.c>",
        "+<*.h>",
        "custom/*.cpp",
        "generated/*.cpp",
        "generated/guider_customer_fonts/*.cpp",
        "generated/guider_fonts/*.cpp",
        "generated/images/*.cpp"
      ]
    }
}

4/6,platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
monitor_speed = 115200
framework = arduino
lib_deps = 
	bblanchon/ArduinoJson@^6.18.5
	sstaub/Ethernet3@^1.5.5
	bodmer/TFT_eSPI@^2.4.25
	lvgl/lv_arduino@^3.0.1

5/6,main.cpp

#include "arduino.h"
#include <stdlib.h>
#include "lvgl.h"
#include <TFT_eSPI.h>

#include <generated/gui_guider.h>
#include <generated/events_init.h>
#include <custom/custom.h>
lv_ui guider_ui;

void setup()
{
    lv_init();
    setup_ui(&guider_ui);
    // events_init(&guider_ui);
    // custom_init(&guider_ui);
}
void loop()
{
    lv_task_handler();
    delay(5);
}

6/6,build error

undefined reference to xxx

Linking .pio\build\esp32dev\firmware.elf
.pio\build\esp32dev\src\main.cpp.o:(.literal._Z5setupv+0x4): undefined reference to `setup_ui'
.pio\build\esp32dev\src\main.cpp.o: In function `setup()':
D:\EVERYDAY\WorkDay\220607_BLT\0608mega/src/main.cpp:26: undefined reference to `setup_ui'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32dev\firmware.elf] Error 1

Two

The library files are all C language files, and the main file is a CPP file.
The header files in the library file are all added with extern C

What should I do? thanks for your help!

Can you show the header file that declares setup_ui?

yes,thanks
setup_ui in gui_guider.h

#ifndef GUI_GUIDER_H
#define GUI_GUIDER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lvgl/lvgl.h"
#include "guider_fonts.h"
typedef struct
{
	lv_obj_t *index;
	lv_obj_t *index_cont_1;
        ...
        lv_obj_t *complete_btn_1_label;
	lv_obj_t *complete_label_1;
}lv_ui;

void setup_ui(lv_ui *ui);
extern lv_ui guider_ui;
void setup_scr_index(lv_ui *ui);
void setup_scr_setup(lv_ui *ui);
void setup_scr_about(lv_ui *ui);
LV_IMG_DECLARE(_setup_alpha_35x35);
LV_IMG_DECLARE(_back48_alpha_35x35);
#ifdef __cplusplus
}
#endif
#endif

and gui_guider.c

#include "lvgl/lvgl.h"
#include <stdio.h>
#include "gui_guider.h"


void setup_ui(lv_ui *ui){
	LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY, 
		LV_THEME_MATERIAL_FLAG_LIGHT, LV_THEME_DEFAULT_FONT_SMALL,  LV_THEME_DEFAULT_FONT_NORMAL, 
		LV_THEME_DEFAULT_FONT_SUBTITLE, LV_THEME_DEFAULT_FONT_TITLE);
	setup_scr_index(ui);
	lv_scr_load(ui->index);
}

This is very common c and h, I don’t know where the problem is, but it feels like a mixed compilation of C and CPP. Because I don’t understand the compilation of pio, I have only used keil before. .
thanks

Technically this source filter isn’t valid, they must be in +<some path> or -<some path> for adding / removing them – maybe that’s a poroblem.

When you clean + build the project again (through the project tasks), does it compile the gui_guider.c file at all?

very thanks,when i change it to +<> ,its good.