# \[Porting\] General issues

**URL:** <https://community.particle.io/t/porting-general-issues/27039>\
**Category:** Libs 2.0 Beta\
**Created:** [November 5, 2016, 3:32pm UTC](https://community.particle.io/t/porting-general-issues/27039 "2016-11-05T15:32:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [November 5, 2016, 3:32pm UTC](https://community.particle.io/t/porting-general-issues/27039/1 "2016-11-05T15:32:30Z")

</div>

**1) Tedious to test a library**

I wonder how the 3rd part library provider does their test… It seems like they make a library repo, whack the entire folder in the `libraries` folder and runs their examples to compile etc.

One method i used is to `symlink`.

The current setup for :particle: requires making another folder, paste the library and compile. I’m sure we have a better way to do this!

**2) Migrate + Contribute not working**

- Tested using: [https://github.com/kennethlimcp/spark-adxl345](https://github.com/kennethlimcp/spark-adxl345)
- `particle library migrate`: Library migrated to v2 format:
- `particle library contribute`: This library could not be imported. Try another library or try this one again later.

Original:

```auto
.
├── LICENSE
├── README.md
├── firmware
│ ├── ADXL345.cpp
│ ├── ADXL345.h
│ ├── binary.h
│ └── examples
│ ├── 1_reg_print.cpp
│ ├── 2_no_lib.cpp
│ └── 3_run.cpp
└── spark.json

```

Migrated:

```auto
Library migrated to v2 format: '/Users/kennethlimcp/Desktop/Arduino-lib-official/spark-adxl345'
KENMBP:spark-adxl345 kennethlimcp$ tree
.
├── LICENSE
├── README.md
├── examples
│ ├── 1_reg_print
│ │ └── 1_reg_print.cpp
│ ├── 2_no_lib
│ │ └── 2_no_lib.cpp
│ └── 3_run
│ └── 3_run.cpp
├── library.properties
└── src
    ├── ADXL345
    │ ├── ADXL345.h
    │ └── binary.h
    ├── ADXL345.cpp
    ├── ADXL345.h
    └── binary.h

```

**3.) We need to be able to use `.ino` in the src folder**

Using the `.cpp` format requires me to create the function prototypes needed in the `.ino` file so that’s cubersome.

Example:

In .ino file

```auto
attachInterrupt(0, interruptRoutine, FALLING);

void interruptRoutine() {
  isr_flag = 1;
}

```

In .cpp file

```auto
void interruptRoutine();

attachInterrupt(0, interruptRoutine, FALLING);

void interruptRoutine() {
  isr_flag = 1;
}

```

**4. Spaces in original library name**

```auto
Adafruit_Sensor kennethlimcp$ p library contribute
Library is not valid. name must only contain letters, numbers, dashes and underscores

KENMBP:Adafruit_Sensor kennethlimcp$ cat library.properties 
name=Adafruit Unified Sensor
version=1.0.2
author=Adafruit <info@adafruit.com>
maintainer=Adafruit <info@adafruit.com>
sentence=Required for all Adafruit Unified Sensor based libraries.
paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries.
category=Sensors
url=https://github.com/adafruit/Adafruit_Sensor
architectures=*

```

**5. License required for each library**

This is not a requirement in the Arduino 3rd party libraries so essentially this requirement makes all ported libraries different from the upstream.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 19, 2016, 6:35pm UTC](https://community.particle.io/t/porting-general-issues/27039/2 "2016-11-19T18:35:13Z")

</div>

I seem to have a similar issue, reported here

> [@Publish a library](https://community.particle.io/t/publish-a-library/26022/8):
>
> @jvanier, I just tried to contribute/publish my first 2.0 lib, but got this Library is not valid. main source is missing main header is missing That’s particularly surprising since the respective “ol’ school” library migrated via particle library migrate without issue, but the subsequent particle library contribute failed (when executed from the same direcory as the previous migrate command). What have I done wrong? BTW, once I will be able to contribute, how could I instruct CLI to bui…

> [@kennethlimcp](#):
>
> 1. Tedious to test a library
> 
> I wonder how the 3rd part library provider does their test.. It seems like they make a library repo, whack the entire folder in the libraries folder and runs their examples to compile etc.
> 
> One method i used is to symlink.
> 
> The current setup for :particle: requires making another folder, paste the library and compile. I'm sure we have a better way to do this!

Having a way to have CLI build an embedded example of the library _ **before** _ you contribute/publish (whithout the extra work of setting up a test project) would be good.

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [November 29, 2016, 8:04am UTC](https://community.particle.io/t/porting-general-issues/27039/3 "2016-11-29T08:04:55Z")

</div>

Thanks for this feedback kenneth!

To make developing and testing libraries easier, we will add a way to compile examples in the library, so the examples can help drive feature development of the library.

The user will be able to cd into an examples folder and run the usual particle compile/flash commands. The tool will internally create a new project on the fly with the library sources and send that to the cloud for compiling.

We will add .ino support in the `src` folder. (cc: @suda) and also in the examples folder

Spaces in the library name is not supported. The library should be renamed to use dashes or underscores. This is necessary to bring the libraries in line with the arduino spec. Also spaces are evil when used with filenames - they cause lots of trouble! 🙂

We can make the license optional for contribution, but I think it should be mandatory for publishing, unless we can get clarity on what a non-licensed library means - it is implicitly in the public domain?

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [November 29, 2016, 4:20pm UTC](https://community.particle.io/t/porting-general-issues/27039/4 "2016-11-29T16:20:56Z")

</div>

> [@mdma](#):
>
> We can make the license optional for contribution, but I think it should be mandatory for publishing, unless we can get clarity on what a non-licensed library means - it is implicitly in the public domain?

The status should remain the same as how the library was originally created. If the 3rd party library provider for Arduino did not provide a license, then it should stay the same.

It just really means more work for a simple port when licensing is mandatory.
