Skip to content

Issue while adding precompile archive #10473

Closed
@thetechguy2016

Description

@thetechguy2016

Hello everyone

i want to create a library but want to use it with archive file.

i create a test library and i got some error while compile.

Steps, I followed:

  1. Create Library structure
   {Library name (test)}/
                   example/
                           test.ino
                   src/
                       esp8266/
                              libtest.a
                       test.h

  1. create test.h , test.cpp and test.ino file

test.h file

#ifndef TEST_H
#define TEST_H

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

#define NAME "AGLOW"
void name();
void data();
#endif

test.cpp

#include <test.h>
void name() {
    Serial.print(NAME);
}
void data() {
    Serial.print(NAME);
}

test.ino file

#include <test.h>
void setup() {
    Serial.begin(115200);    
    name();
}
void loop() {}

  1. I compile the code with dot_a_linkage=true then i will get the test.a file in temporary folder .

  2. now i delete the test.cpp file and add test.a file inside the esp8266 folder as mentioned above.

  3. and change the test.a file name to libtest.a

  4. now i compile the code with this library.properties, but nothing works

name=TEST
version=1.0.0
author=Vipul Garg 
maintainer=Vipul Garg
sentence=A library use to do
paragraph=Supports HTTPS1.1
category=Communication
url=https://xyz.com
architectures=esp8266
includes=test.h
precompiled=true
ldflag=-ltest
  1. i got this below error
Used: /Users/vipulgarg/Documents/Arduino/libraries/test
/Users/vipulgarg/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /var/folders/4p/d03ndbt94pj3bw26wnzvly580000gn/T/arduino_build_447457/sketch/test1.ino.cpp.o:(.text.setup+0x8): undefined reference to `name()'
/Users/vipulgarg/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /var/folders/4p/d03ndbt94pj3bw26wnzvly580000gn/T/arduino_build_447457/sketch/test1.ino.cpp.o: in function `setup':
/Users/vipulgarg/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266/HardwareSerial.h:76: undefined reference to `name()'
collect2: error: ld returned 1 exit status

  1. if i add test.cpp again in the src folder everything works fine.

Please help me out i have tried for more than 5 days still got error.
my test library is attached to this issue.

test.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: DocumentationRelated to Arduino's documentation contentarduino-builderThe tool used to handle the Arduino sketch compilation process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions