Arduino.h not found

Hello,

I’m new to Platformio and installed the integration for Clion. I created a new project for Arduino diecimilaatmega168. I can compile and upload my program. But Clion cannot find the Arduino.h, all functions (delay, …) are marked red.

My platformio.ini:

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

upload_port = COM[6]

and my main.cpp:

#include <Arduino.h>

void setup() 
{
// write your initialization code here
}

void loop() 
{
// write your code here
	digitalWrite(13, HIGH);
	delay(500);
	digitalWrite(13, LOW);
	delay(500);
}

Also this is shown when i cretae a new project:

C:\Users\xxx\cygwin64\bin\cmake.exe -DCMAKE_BUILD_TYPE=diecimilaatmega168 -DCMAKE_MAKE_PROGRAM=/usr/bin/make.exe -DCMAKE_C_COMPILER=/usr/bin/gcc.exe -DCMAKE_CXX_COMPILER=/usr/bin/g++.exe -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/gersdo01/onc/study/hsis/untitled
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/xxx/onc/study/hsis/untitled/cmake-build-diecimilaatmega168

Problems were encountered while collecting compiler information:
	Unexpected compiler output. This compiler might be unsupported.
	If you are using GCC/Clang, please report the bug in https://youtrack.jetbrains.com/issues/CPP.

Can anybody help me with this problem?

Thanks,
Tobias

This looks like cmake is configured to use the system wide C and C++ compilers. The Arduino should be using the one that got downloaded to ${HOME}/.platformio. Also, I’m wondering why cmake is even being used, none of my Uno/Duemilanove/Nano/NormDuino boards use it – they use avr-g++.

I also see “codeblocks” in the above. I imagine that you would need to add the avr-gcc/avr-g++ compilers as a “kit” in CodeBlocks to be able to compile for the Arduino.

How exactly did you create the new project? I use

pio init --board uno --ide codeblocks

When I need to use CodeBlocks as my IDE.

Cheers,
Norm.

I created it directly with the Clion GUI. Clion has options to create Platformio projects since I’ve installed the plugin.
I now tried it with
pio init --board uno --ide clion
what causing different errors:

C:\Users\xxx\cygwin64\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/make.exe -DCMAKE_C_COMPILER=/usr/bin/gcc.exe -DCMAKE_CXX_COMPILER=/usr/bin/g++.exe -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/gersdo01/onc/study/hsis/test
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:33 (add_executable):
  No SOURCES given to target: Z_DUMMY_TARGET

Weird!

In a command line session, try the following please:

mkdir test
cd test
Pio init --board uno

Then, check if src has a *.cpp file iside and if so:

pio run

Which should compile without problem. If so, the problem is in the IDE, which it seems, is still trying to use the default (x86?) compiler.

Cheers,
Norm.

Yes, it works. My question was intended to determine the problem with Clion.

Best regards,
Tobias

Thanks for testing that.

I might be wrong, it happens (!), but it seems to me that the clion system, using cmake is picking up the default compilers rather than those for the Arduino board.

I’m afraid I have no idea how to fix that particular problem, sorry. :frowning_face:

Cheers,
Norm.

1 Like

Are you using the CLion plugin as described in the documentation? CLion — PlatformIO latest documentation and https://plugins.jetbrains.com/plugin/13922-platformio-for-clion.

Please exactly follow the installation and setup method for a project as outlined in the doc.

Thanks for your reply.

I tried to use it like described in the doc, but I’m not sure if I got the part with the CMAke toolchain right, because it’s explained in detail!
I tried to set the CMake options manually but it didn’t help. What I need to change in my case?

“Toolchain: Use default: Cygwin” seems wrong and isn’t talked about in the docs. What CLion version is this?

The doc says default toolchain (that’s cygwin in my case, I don’t have another toolchain…).

CLion 2020.2.4
Build #CL-202.7660.37, built on October 7, 2020

Okay you definitely need a different toolchain.

Do a File → Settings → Build, Execution and Deployment → Toolchain, click on the Add / plus button, and select MinGW.

Now sadly one can not select the the toolchain root folder C:\Users\<user>\.platformio\packages\toolchain-atmelavr\ for “environment” (you said you’re working with an AVR based Arduino Uno so the right toolchain in this case is toolchain-atmelavr, might be different for diffrerent people). So please download MinGW from http://mingw-w64.org/doku.php/download/mingw-builds and install it, if you don’t already have one. Then your “environment” should be something like “C:\Program Files (x86)\mingw-w64\i686-7.2.0-posix-dwarf-rt_v5-rev1\mingw32”.

For the C, C++ compiler and Debugger you should however then select the avr-gcc, avr-g++ and avr-gdb files from C:\Users\<user>\.platformio\packages\toolchain-atmelavr\bin.

Works for me.

2 Likes

Thank you!
Installed MinGW and it works.

Best regards, Tobias