I would like to use the external libraries that are downloaded by Arduino IDE into the default sketchbook location (~/Arduino/libraries/).

If you open Library Manager in Arduino IDE and if you install an external library (e.g DHT sensor library 1.3.7 and its dependency Adafruit Unified Sensor 1.0.3) then it will be downloaded to the sketchbook location and you can use them freely in case of writing code in Arduino IDE.

However I really like auto code completion, managing source code in GIT repository, formatting source lines, etc. which functionalities are not provided by Arduino IDE, so I changed to CLion.

I have installed CLion and Arduino Support 1.4.4 Plugin and created a new Arduino Sketch Project.

Project Structure:



#include <Arduino.h>
#include "User_Setup.h"
#include <libs/Adafruit_Sensor/Adafruit_Sensor.h>
#include <libs/DHT/DHT.h>

DHT *dht;

void setup() {
    dht = new DHT(7, DHT22);

void loop() {


So I have copied over the downloaded libraries from ~/Arduino/libraries folder to the project folder under libs folder.

When I try to upload the code to Arduino Board I am getting the following in the log:

undefined reference to `DHT::DHT(unsigned char, unsigned char, unsigned char)'

Could somebody please explain what is wrong here.

Thank you very much!

  • Are you sure you are using the correct method signature, it seems that this method signature of the constructor does not exist: dht = new DHT(7, DHT22); takes 2 args, versus what is the complain is 3 args, something is not right
    – omars
    Commented Jan 24, 2020 at 10:59

2 Answers 2


In my opinion, the easiest way for the beginner is to use Platformio, it sets up CLion project automatically.

See docs for more info.

  • do you have any link to configure platform IO, I'm using CLion as an editor and arduino IDE to compile and deploy to microcontroller, if there is any guide available it would be helpful to share. thanks
    – omars
    Commented Jan 24, 2020 at 10:57
  • @OmarS. see the edited answer. It also configures build tasks for uploading, so no need to use Arduino IDE. But read the docs carefully: remember pressing "build" hotkey for all tasks instead of "run".
    – artem
    Commented Jan 24, 2020 at 21:14

Did you add your libraries to the cmake files?

I don't have any experience with CLion but undefined reference normally means that the linker couldn't find the function/class your are using.

So make sure the libraries are compiled and the linker knows where to find the object files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.