ESP-IDF v4.1怎么生成静态库和调用静态库

elegoqq
Posts: 9
Joined: Fri Sep 25, 2020 3:40 am

ESP-IDF v4.1怎么生成静态库和调用静态库

Postby elegoqq » Fri Sep 25, 2020 3:42 am

请指教,多谢了

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: ESP-IDF v4.1怎么生成静态库和调用静态库

Postby ESP_morris » Fri Sep 25, 2020 9:42 am


elegoqq
Posts: 9
Joined: Fri Sep 25, 2020 3:40 am

Re: ESP-IDF v4.1怎么生成静态库和调用静态库

Postby elegoqq » Sat Sep 26, 2020 2:17 am

这个方法可行,非常感谢!

elegoqq
Posts: 9
Joined: Fri Sep 25, 2020 3:40 am

Re: ESP-IDF v4.1怎么生成静态库和调用静态库

Postby elegoqq » Sat Sep 26, 2020 2:51 am

按下面的方法写,是可以调用simple_math库
add_library(simple_math STATIC
"math_lib/myadd.c"
"math_lib/mysub.c")

target_link_libraries(${COMPONENT_LIB} PUBLIC "simple_math")

但是把add_library删除只保留target_link_libraries就找不到simple_math库
target_link_libraries(${COMPONENT_LIB} PUBLIC "simple_math")
报错:ld.exe: cannot find -lsimple_math
实际上在build\esp-idf\main\路径下有已经生成的libsimple_math.a,该怎样找到它呢?

elegoqq
Posts: 9
Joined: Fri Sep 25, 2020 3:40 am

Re: ESP-IDF v4.1怎么生成静态库和调用静态库

Postby elegoqq » Mon Sep 28, 2020 2:40 am

库生成了,也放到了main路径下,链接时找不到,这是什么原因?
GATT_SERVER/main/libsimple_math.a

GATT_SERVER/main/CMakeLists.txt 书写如下
target_link_libraries(${COMPONENT_LIB} PUBLIC "simple_math")

Who is online

Users browsing this forum: No registered users and 53 guests