Arduino Compiling with libraries (pio seems to not compile cpp of the libraries)

I have created a project using plateformIO. I am trying to compile the example files provided by the Adafruit_SSD1306 library. Currently the compilation doesn’t work due to many errors (undeclared function in the scope). These errors seem to come from a wrong compilation of the libraries because these functions are coming from Adafruit_GFX.

Arduino software works with no trouble on the same file. Do you have idea for solving this issue?

The .pioenvs seems to contain the right files of each library (.ccp and .h)

Contents of my platformio.ini file

[platformio]
lib_dir = ~/Documents/Arduino/libraries

[env:megaatmega2560]
platform = atmelavr
framework = arduino
board = megaatmega2560

Compilation log:

Platform atmelavr

Updating toolchain-atmelavr package:
Versions: Current=1, Latest=1 [Up-to-date]
Updating tool-avrdude package:
Versions: Current=2, Latest=2 [Up-to-date]
Updating framework-arduinoavr package:
Versions: Current=28, Latest=28 [Up-to-date]
PlatformIO has been successfully upgraded to 2.8.5!

[Mon Apr 18 12:14:25 2016] Processing megaatmega2560 (platform: atmelavr, board: megaatmega2560, framework: arduino)

avr-g++ -o .pioenvs/megaatmega2560/src/test.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DARDUINO=10608 -DPLATFORMIO=020805 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant -I.pioenvs/megaatmega2560/SPI -I.pioenvs/megaatmega2560/Wire -I.pioenvs/megaatmega2560/Wire/utility -I.pioenvs/megaatmega2560/Adafruit-GFX-Library -I.pioenvs/megaatmega2560/Adafruit_SSD1306 src/test.cpp
src/test.cpp: In function ‘void setup()’:
src/test.cpp:94:16: error: ‘testdrawline’ was not declared in this scope
testdrawline();
^
src/test.cpp:100:16: error: ‘testdrawrect’ was not declared in this scope
testdrawrect();
^
src/test.cpp:106:16: error: ‘testfillrect’ was not declared in this scope
testfillrect();
^
src/test.cpp:112:18: error: ‘testdrawcircle’ was not declared in this scope
testdrawcircle();
^
src/test.cpp:123:21: error: ‘testdrawroundrect’ was not declared in this scope
testdrawroundrect();
^
src/test.cpp:127:21: error: ‘testfillroundrect’ was not declared in this scope
testfillroundrect();
^
src/test.cpp:131:20: error: ‘testdrawtriangle’ was not declared in this scope
testdrawtriangle();
^
src/test.cpp:135:20: error: ‘testfilltriangle’ was not declared in this scope
testfilltriangle();
^
src/test.cpp:140:16: error: ‘testdrawchar’ was not declared in this scope
testdrawchar();
^
src/test.cpp:146:18: error: ‘testscrolltext’ was not declared in this scope
testscrolltext();
^
src/test.cpp:176:72: error: ‘testdrawbitmap’ was not declared in this scope
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
^
avr-g++ -o .pioenvs/megaatmega2560/FrameworkArduino/IPAddress.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant .pioenvs/megaatmega2560/FrameworkArduino/IPAddress.cpp
avr-g++ -o .pioenvs/megaatmega2560/FrameworkArduino/PluggableUSB.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant .pioenvs/megaatmega2560/FrameworkArduino/PluggableUSB.cpp
scons: *** [.pioenvs/megaatmega2560/src/test.o] Error 1
avr-g++ -o .pioenvs/megaatmega2560/FrameworkArduino/Print.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant .pioenvs/megaatmega2560/FrameworkArduino/Print.cpp
=================================================== [ ERROR ] Took 0.85 seconds ===================================================

Hi @guuk!

Please move setup and loop functions to the end of a file, they should be placed below all test* functions.

Thank you for your answer. I don’t see this switch…