Static library - call target out of range

lchazall
Posts: 7
Joined: Tue Nov 22, 2016 7:26 pm

Static library - call target out of range

Postby lchazall » Wed Nov 23, 2016 10:05 am

Hi,

I am having trouble compiling a project which is including a static library (a ".a" file).

When I make the project I get those two errors :

Code: Select all

componentpath/lib/xtensa-esp32-elf/mylib.a(user.o): In function `delete_user':
user.c:(.text.delete_user+0x5): dangerous relocation: call8: call target out of range: free
componentpath/lib/xtensa-esp32-elf/mylib.a(user.o): In function `user_create':
user.c:(.text.user_create+0x5): dangerous relocation: call8: call target out of range: malloc
But in the make stdout, I can see that the "-mlongcalls" option is enabled, so why would malloc and free be out of range ? xtensa should link them, am I wrong ?

Here is my project tree.
  • components
    • MyComponent
      • include
        • library headers
      • lib
        • xtensa-esp32-elf
          • mylib.a
      • component.mk
        • COMPONENT_ADD_LDFLAGS=$(COMPONENT_PATH)/lib/xtensa-esp32-elf/mylib.a -l$(COMPONENT_NAME)
        • include $(IDF_PATH)/make/component_common.mk
      • mycomp.c
  • main
    • main.c
    • component.mk => include $(IDF_PATH)/make/component_common.mk
  • Makefile => include $(IDF_PATH)/make/project.mk
Best regards,
lchazall

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

Re: Static library - call target out of range

Postby ESP_Sprite » Wed Nov 23, 2016 11:03 am

Do you compile the lib from source? If you add the source as a component to your esp-idf project, it should work just fine. If not, maybe whatever C-flags you use aren't compatible with what esp-idf expects.

lchazall
Posts: 7
Joined: Tue Nov 22, 2016 7:26 pm

Re: Static library - call target out of range

Postby lchazall » Wed Nov 23, 2016 11:47 am

Thank you for your answer.

The lib is provided by a third party.
Do they have to recompile with specific options ? if so, which ones ?
Or how can I compile my project without recompiling this lib ?
Best regards,
lchazall

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Static library - call target out of range

Postby ESP_igrr » Wed Nov 23, 2016 3:58 pm

This error would happen if the static library is compiled without mlongcalls. Check with the third party about the flags they are using to compile the lib.

lchazall
Posts: 7
Joined: Tue Nov 22, 2016 7:26 pm

Re: Static library - call target out of range

Postby lchazall » Fri Dec 02, 2016 9:43 am

Hi,

Compiling the third party lib with the "-mlongcalls" option did the job.
Thank you for your help.
Best regards,
lchazall

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

Re: Static library - call target out of range

Postby pratik.yadav.455 » Sat Nov 11, 2017 5:54 am

Hello,

I am porting libxml in esp-idf i did same as you did, but i have not added source code, because i want to use lib file when ever my library is needed.
my component folder is structured as follow:

component
--libmxml
--include
(Contain Header file)
--lib
(contain libmxml.a file)
--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


When I compile this , I got following error

user/esp-idf-v2.1/components/libmxml/lib/libmxml.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status

What i am doing wrong? What i should do?
Can anyone give me any suggestion ?

Who is online

Users browsing this forum: No registered users and 194 guests