天天看點

ESP8266/ESP32連結靜态庫檔案的方法

libmyapp.a

檔案為例。

1. ESP8266 non_os 和 ESP8266 RTOS SDK V2.x

libmyapp.a

檔案放到

lib

檔案夾,然後在

app\Makefile

中的

LINKFLAGS_eagle.app.v6 = \

後面添加一行

-lmyapp \

如圖:

ESP8266/ESP32連結靜态庫檔案的方法

其他的相關

.c

檔案和

.h

檔案放在

app\myapp

檔案夾中。

2.ESP8266 RTOS SDK V3.0+ 和ESP-IDF

components

的形式添加。

首先将

components

檔案夾組織如下:

components
  ├── CMakeLists.txt
  ├── Kconfig
  ├── component.mk
  └── myapp
      ├── CMakeLists.txt
      ├── Kconfig
      ├── component.mk
      ├── device.c
      ├── user.c
      ├── include
      │   ├── device.h
      │   ├── myapp.h
      │   └── user.h
      └── lib
          └── libmyapp.a
           

components\CMakeLists.txt

檔案内容:

set(COMPONENT_SRCDIRS "myapp")
register_component()
           

components\component.mk

檔案内容:

COMPONENT_SRCDIRS := myapp
LIBS += myapp
COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/myapp/lib $(addprefix -l,$(LIBS))
           

components\Kconfig

檔案内容:

menu "MYAPP"
config MYAPP_ENABLE
bool "Enable MYAPP"
default "y"
endmenu
           

components\myapp\CMakeLists.txt

檔案内容:

set(COMPONENT_SRCDIRS ".")
set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()
           

components\myapp\component.mk

檔案内容:

COMPONENT_SRCDIRS := .
COMPONENT_ADD_INCLUDEDIRS:=include
           

參考文獻:

編譯系統 — ESP-IDF 程式設計指南 v3.2 文檔

求助:cannot find entry symbol 調用了别人的靜态庫編譯不通過 - ESP32 Forum

繼續閱讀