How to Link third party library in esp-idf

pratik.yadav.455
Posts: 23
Joined: Thu Oct 26, 2017 7:34 am

How to Link third party library in esp-idf

Postby pratik.yadav.455 » Sat Nov 11, 2017 12:13 pm

Hello,

I want to port mxml library in esp-idf where i want to use my static libmxml.a. For that i added One folder in Component , it's structure is as following:

-- component
-- libxml
-- include
(contain header file)
-- lib
(contain lib file libmxml.a)
--component.mk
COMPONENT_ADD_LDFLAGS=$(COMPONENT_PATH)/lib/libmxml.a -l$(COMPONENT_NAME)
include $(IDF_PATH)/make/component_common.mk

--main
--main.c
contain application code
-- component.mk
include $(IDF_PATH)/make/component_common.mk

Referance @ https://esp32.com/viewtopic.php?f=13&t= ... rary#p2298
after compiling this project i get following error:

/esp-idf-v2.1/components/libmxml/lib/libmxml.a: error adding symbols: File format not recognized

Am i Doing anything wrong?
Can anyone provide suggestion regarding this or guidance to port library in esp-idf?

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: How to Link third party library in esp-idf

Postby ESP_Sprite » Sat Nov 11, 2017 3:40 pm

How did you compile this static library?

pratik.yadav.455
Posts: 23
Joined: Thu Oct 26, 2017 7:34 am

Re: How to Link third party library in esp-idf

Postby pratik.yadav.455 » Fri Nov 17, 2017 6:12 am

I have its all ".o" file, using those files I generate lib using xtensa too-chain's AR command.
so when i compile my application with mxml function. i get following error:

Code: Select all


/libxml.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status

I have also added tried to generate my lib using xtensa ranlib. i made following makefile to generate lib:

Code: Select all


AR = xtensa-esp32-elf-ar

RAN = xtensa-esp32-elf-ranlib
ARFLAGS = cru 

libxml.a:
	$(RM) $@
	$(AR) $(ARFLAGS)  $(LIBOBJS)
	$(RANLIB) $@

where LIBOBJS contain my all ".o " files.

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: How to Link third party library in esp-idf

Postby ESP_Sprite » Sat Nov 18, 2017 1:36 pm

Pretty sure the way you call $(AR) in the makefile is missing an $@ somewhere...

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 109 guests