Esp-idf: How to add my own static library file ( .a file ) for ESP32 to use CMAKE above esp-idf?

Created on 11 Jun 2019  ·  10Comments  ·  Source: espressif/esp-idf

All 10 comments

Can you give me a detailed procedure?

It should be the same as in plain old CMake:

add_library(<library-name> STATIC <your-source-files>)

That should compile your source files and archive them to a .a file. You can then link it to the enclosing component:

target_link_libraries(COMPONENT_LIB <PUBLIC|PRIVATE> <library-name>)

Or am I missing something with your question?

I know how to create the .a files.
but I don't know how to add a .a file to my project.
Can you give me an example base on the HelloWorld project?

You mean a pre-built .a file, you want to link that to your project? You can add it as an imported library:

add_library(<library-name> STATIC IMPORTED)
set_property(TARGET <library-name> PROPERTY IMPORTED_LOCATION <path-to-library-archive>)

See components/esp_wifi/CMakeLists.txt for how we include the wifi libraries (libcoexist.a, libmesh.a, etc.)

你可以自己写.mk规则,然后在项目Makefile中添加引用

@WangYifa Can this be closed?

@WangYifa Thanks for reporting this, due to that IDF issue template has been ignored, will close the ticket for now. For questions, you can raise a post on our forum. Thanks.

I've been dealing with this for a long time. but I couldn't get it to work and finally decided to write here. please make a small "hello world" example.

Ok, will do @drony. This will be low priority though because using a pre-built binary isn't exactly specific to ESP-IDF and there is already some example mentioned in esp_wifi.

@renzbagaporo thanks for response. i read everything about this problem. bu i can't get any result. and i'm tired:(

similiar basic sample is here. can you help me/us(i thing lot of people strugling this issue)
https://github.com/espressif/esp-idf/issues/4210

thanks is advance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  4Comments

waayst picture waayst  ·  4Comments

okasha55 picture okasha55  ·  3Comments

jakkra picture jakkra  ·  3Comments

bfriedkin picture bfriedkin  ·  4Comments