Steps to use libraries 2.0

@jvanier, should I updated to a newer node version? If so, which?

It’s best if you just keep using the same version of Node. It’s more representative of what other users will see.

The CLI is supposed to work on Node 4 or later.

When you have a chance you can try the 2.0.0-libraries.4 version that has the es6-promisify fix.

1 Like

@jvanier, FYI here is what the latest install puts out. Running particle --version correctl reports 2.0.0-libraries.4

C:\SPARK\TESTING>npm install -g https://github.com/spark/particle-cli/releases/download/v2.0
.0-libraries.4/particle-cli-2.0.0-libraries.4.tgz
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a
RegExp DoS issue
npm WARN excluding symbolic link test\server\static\ie8-polyfill.js -> ../../../ie8-polyfill
.js
\
> spawn-sync@1.0.15 postinstall C:\Users\Paul\AppData\Roaming\npm\node_modules\particle-cli\
node_modules\yeoman-environment\node_modules\inquirer\node_modules\external-editor\node_modu
les\spawn-sync
> node postinstall

npm WARN excluding symbolic link test\server\static\ie8-polyfill.js -> ../../../ie8-polyfill
.js

> spawn-sync@1.0.15 postinstall C:\Users\Paul\AppData\Roaming\npm\node_modules\particle-cli\
node_modules\particle-cli-library-manager\node_modules\yeoman-generator\node_modules\yeoman-
test\node_modules\inquirer\node_modules\external-editor\node_modules\spawn-sync
> node postinstall

|
> serialport@3.1.2 install C:\Users\Paul\AppData\Roaming\npm\node_modules\particle-cli\node_
modules\serialport
> node-pre-gyp install --fallback-to-build

[serialport] Success: "C:\Users\Paul\AppData\Roaming\npm\node_modules\particle-cli\node_modu
les\serialport\build\Release\serialport.node" is installed via remote
C:\Users\Paul\AppData\Roaming\npm\particle -> C:\Users\Paul\AppData\Roaming\npm\node_modules
\particle-cli\bin\particle.js
particle-cli@2.0.0-libraries.4 C:\Users\Paul\AppData\Roaming\npm\node_modules\particle-cli
├── cli-spinner@0.2.5
├── xtend@4.0.1
├── semver@5.3.0
├── es6-promisify@4.1.0 (es6-promise@3.2.1)
├── temp@0.8.3 (os-tmpdir@1.0.1, rimraf@2.2.8)
├── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, has-an
si@2.0.0, strip-ansi@3.0.1)
├── cli-table@0.3.1 (colors@1.0.3)
├── glob@4.5.3 (inherits@2.0.1, once@1.3.3, inflight@1.0.5, minimatch@2.0.10)
├── node-wifiscanner2@1.2.0 (os-locale@1.4.0)
├── when@3.7.7
├── inquirer@0.11.4 (ansi-regex@2.0.0, strip-ansi@3.0.1, ansi-escapes@1.4.0, rx-lite@3.1.2,
through@2.3.8, cli-width@1.1.1, figures@1.7.0, string-width@1.0.2, readline2@1.0.1, cli-curs
or@1.0.2, run-async@0.1.0)
├── form-data@1.0.0-rc4 (async@1.5.2, combined-stream@1.0.5, mime-types@2.1.11)
├── binary-version-reader@0.4.0 (buffer-crc32@0.2.5, h5.buffers@0.1.1)
├── latest-version@2.0.0 (package-json@2.4.0)
├── hogan.js@2.0.0
├── request@2.74.0 (tunnel-agent@0.4.3, aws-sign2@0.6.0, oauth-sign@0.8.2, forever-agent@0.6
.1, is-typedarray@1.0.0, caseless@0.11.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, js
on-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.1, qs@6.2.1, node-uuid@1.4.7, combin
ed-stream@1.0.5, mime-types@2.1.11, bl@1.1.2, hawk@3.1.3, http-signature@1.1.1, har-validato
r@2.0.6)
├── yargs@4.8.1 (get-caller-file@1.0.2, decamelize@1.2.0, lodash.assign@4.2.0, y18n@3.2.1, w
hich-module@1.0.0, set-blocking@2.0.0, require-main-filename@1.0.1, require-directory@2.1.1,
 window-size@0.2.0, yargs-parser@2.4.1, os-locale@1.4.0, string-width@1.0.2, cliui@3.2.0, re
ad-pkg-up@1.0.1)
├── particle-api-js@6.0.4 (superagent-prefix@0.0.2, stream-http@2.2.1, superagent@2.2.0)
├── handlebars@4.0.5 (async@1.5.2, source-map@0.4.4, optimist@0.6.1, uglify-js@2.7.3)
├── moment@2.14.1
├── lodash@3.10.1
├── softap-setup@1.1.4 (nconf@0.7.2, node-rsa@0.2.30)
├── yeoman-environment@1.6.3 (escape-string-regexp@1.0.5, log-symbols@1.0.2, text-table@0.2.
0, untildify@2.1.0, debug@2.2.0, diff@2.2.3, globby@4.1.0, mem-fs@1.1.3, grouped-queue@0.3.2
, inquirer@1.1.2, lodash@4.15.0)
├── particle-cli-library-manager@0.0.4-develop.3 (superagent-prefix@0.0.2, babel-plugin-tran
sform-runtime@6.12.0, app-root-path@1.3.0, properties-parser@0.3.1, verror@1.8.1, mkdirp@0.5
.1, tar-stream@1.5.2, superagent@1.8.4, gunzip-maybe@1.3.1, fs-extra@0.30.0, tar.gz@1.0.5, y
eoman-generator@0.24.1, async@2.0.1)
├── babel-runtime@6.11.6 (regenerator-runtime@0.9.5, core-js@2.4.1)
└── serialport@3.1.2 (bindings@1.2.1, es6-promise@3.2.1, commander@2.9.0, nan@2.4.0, object.
assign@4.0.4, debug@2.2.0)

C:\SPARK\TESTING>
1 Like

@jvanier, I created an app directory under which I added an src directory. I imported the neopixel library (since I couldn’t import any other!) and used one of the examples files and placed it in the src directory (rainbow.cpp). When I compile (not flash) from the app directory I get:

C:\SPARK\TESTING\libtest>particle compile photon . --target 0.6.0-libraries.1

Compiling code for photon
Targeting version: 0.6.0-libraries.1

Including:
    C:/SPARK/TESTING/libtest/project.properties
    C:/SPARK/TESTING/libtest/src/rainbow.cpp
attempting to compile firmware
Compile failed. Exiting.
Now using node v0.10.44
Processing  /workspace/project.properties
Skipping .properties file
Processing  /workspace/rainbow.cpp
Skipping .cpp file
Now using node v6.2.1
particle-cli v1.16.0-develop.1

! A newer version (1.16.0) of particle-cli is available.
! Upgrade now by running: npm install -g particle-cli

particle-cli v1.16.0-develop.1

! A newer version (1.16.0) of particle-cli is available.
! Upgrade now by running: npm install -g particle-cli

Cannot install library: directory '/workspace' is a 'simple' format project, please change t
o a 'extended' format.
fatal: repository '/firmware' does not exist
make -C ../modules/photon/user-part all
make[1]: Entering directory '/firmware/modules/photon/user-part'
make -C ../../../user
make[2]: Entering directory '/firmware/user'
Building cpp file: /workspace/rainbow.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-m/workspace/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFO
RM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_P
LATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPROD
UCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING
=0.6.0-rc.1 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../c
ommunication/src -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I.
./hal/src/stm32 -I../hal/src/photon/api -I../platform/shared/inc -I../platform/MCU/STM32F2xx
/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platfor
m/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driv
er/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/
inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/In
clude -I../dynalib/inc -I/workspace/ -I./libraries -I. -MD -MP -MF ../build/target/user/plat
form-6-m/workspace/rainbow.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-er
ror=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -
DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLAT
FORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCL
UDE_SOURCE_INFO -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000
-DMODULAR_FIRMWARE=1 -DMODULE_VERSION=4 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPEND
ENCY=4,2,100 -D_GNU_SOURCE -D_WINSOCK_H -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fn
o-rtti -fcheck-new -std=gnu++11 -c -o ../build/target/user/platform-6-m/workspace/rainbow.o
/workspace/rainbow.cpp
/workspace/rainbow.cpp:9:52: fatal error: neopixel/neopixel.h: No such file or directory
 #include "neopixel/neopixel.h" // use for Build IDE
                                                    ^
compilation terminated.
../build/module.mk:261: recipe for target '../build/target/user/platform-6-m/workspace/rainb
ow.o' failed
make[2]: *** [../build/target/user/platform-6-m/workspace/rainbow.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/recurse.mk:11: recipe for target 'user' failed
make[1]: *** [user] Error 2
make[1]: Leaving directory '/firmware/modules/photon/user-part'
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed
make: *** [modules/photon/user-part] Error 2

C:\SPARK\TESTING\libtest>

@jvanier, the reason I could not add other libraries is that the upper/lower case letters in the library name need to match exactly with the library’s name. Since the libraries are listed in all-caps, you need to get the correct spelling by viewing the “i” information for that library. This makes the process painful.

1 Like

We are still missing the compatibility layer in the compile server to make the old style #include "neopixel/neopixel.h" work. For now you can have to use #include "neopixel.h" directly, à la Arduino.

You can now use any public library, not just neopixel anymore.

What’s worrying me is that the project structure is being flattened. The log show Building cpp file: /workspace/rainbow.cpp instead of Building cpp file: /workspace/src/rainbow.cpp

Due to the project being flattened, it’s not possible to compile projects with libraries on Windows.

We’ll make the library name case insensitive.

DOH!!! I missed that!

The library name is ALREADY case sensitive. It’s just that getting the correct name from the Web IDE is a pain.

1 Like

What is doing the flattening on windows that it would not do on Linux?

It must have to do with path separators being different.

That path is being built on the server, right? So windows uses ‘’ versus linux which uses ‘/’ for path separation. Can’t that be fixed in particle.js before sending to the server?

You got it chief. I just gotta do it :smile:

1 Like

@jvanier,

tested with particle-cli-2.0.0-libraries.4 for:

  • 0.5.3-rc.3
  • 0.6.0-libraries.1
KENMBP:cli-lib kennethlimcp$ pcp --target 0.5.3-rc.3

Compiling code for photon
Targeting version: 0.5.3-rc.3

Including:
    /Users/kennethlimcp/Desktop/cli-lib/project.properties
    /Users/kennethlimcp/Desktop/cli-lib/src/application.cpp
attempting to compile firmware 
downloading binary from: /v1/binaries/57c63d9ed66d10de4d7faf08
saving to: photon_firmware_1472609687126.bin
Compile succeeded.
Saved firmware to: /Users/kennethlimcp/Desktop/cli-lib/photon_firmware_1472609687126.bin
KENMBP:cli-lib kennethlimcp$ pcp --target 0.6.0-libraries.1

Compiling code for photon
Targeting version: 0.6.0-libraries.1

Including:
    /Users/kennethlimcp/Desktop/cli-lib/project.properties
    /Users/kennethlimcp/Desktop/cli-lib/src/application.cpp
attempting to compile firmware 
	downloading binary from: /v1/binaries/57c63dd9d6e4eeb04d34a98d
saving to: photon_firmware_1472609728919.bin
Compile succeeded.
Saved firmware to: /Users/kennethlimcp/Desktop/cli-lib/photon_firmware_1472609728919.bin

Public libraries are working but a little confusing:

KENMBP:cli-lib kennethlimcp$ p library add stepper
Library stepper not found
KENMBP:cli-lib kennethlimcp$ p library add spark-stepper
Library spark-stepper not found
KENMBP:cli-lib kennethlimcp$ p library add Stepper

Took me a while to figure out which name to use.

Do you still have the same issue? If so, what are the steps to reproduce?

Nope, I haven’t got that issue anymore.
After I upgraded all my devices from 0.5.2 to 0.6.0-rc.1 I could also go to 0.6.0-libraries.1, so I can’t reproduce it anymore either.

You can use 0.6.0-rc.1 and 0.6.0-libraries.1 interchangeably. They are the same firmware, only difference is 0.6.0-libraries.1 goes thru the new compiler infrastructure.

Has development stalled here?
We are still at v14 in above link and the missing particle-library-manager message still pops up when installing from that zip.

1 Like

Thanks for the reminder. I updated the dependencies for the CLI and installed it successfully on Windows. Let me know if that fixes the issue for you too.

@jvanier, just installed it and only warnings I received were these:

C:\SPARK\TESTING>npm install -g https://github.com/spark/particle-cli/releases/download/v2.0
.0-libraries.15/particle-cli-2.0.0-libraries.15.tgz
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a
RegExp DoS issue
npm WARN excluding symbolic link test\server\static\ie8-polyfill.js -> ../../../ie8-polyfill
.js
npm WARN excluding symbolic link test\server\static\ie8-polyfill.js -> ../../../ie8-polyfill
.js

Everything else seemed to installed just fine.

1 Like

I updated the instructions for the latest CLI beta. It comes with a few new things:

The current default firmware 0.5.3 now supports libraries so no need to compile with --target 0.6.0-rc.2

Simple projects now support libraries so you can compile an ino file next to a project.properties for quick apps!

Private libraries are available in libs 2.0. Publishing is now a 2 step process: contribute a new private version then publish that version publicly.

I’m going to post the instructions to add libraries to Dev right after this.

By the way, we dropped the version number back to 1.18.0 because there are not enough user-visible changes to warrant a 2.0 release.

A post was split to a new topic: Using libraries in Particle Dev