Using arduino libraries for ESP32 in visual studio code.

manfre90
Posts: 3
Joined: Sun Dec 04, 2022 3:27 pm

Using arduino libraries for ESP32 in visual studio code.

Postby manfre90 » Wed Dec 28, 2022 5:06 pm

Hi, sorry for the newbie question...
Just asking if it's possibile to mix arduino libraries (written in cpp ?) with standard c; like in project started in vs code with the esp-idf estension.

I tryied a project using arduino as component with the extern 'C' in the main.cpp but I can't compile, the compiler won't find Arduino.h even if it's in the include path.

I just need to drive a stepper with a ULN2003A and I cant find nothing in c. All examples are with the Stepper.h from Arduino.

Thanks in advance

priteshp
Posts: 1
Joined: Wed Apr 10, 2019 7:56 pm

Re: Using arduino libraries for ESP32 in visual studio code.

Postby priteshp » Tue Jan 03, 2023 2:24 pm

I had similar errors when compiling my code with arduino-as-component package in VS Code. The issue I found and fixed is in top level CMakeList.txt file. The 'EXTRA_COMPONENT_DIRS' would not accept relative path to my "arduino-as-component/components" folder. But if I set full path, my code would compile. Try it out.

FRANCISCO2020
Posts: 21
Joined: Mon Sep 20, 2021 9:13 am

Re: Using arduino libraries for ESP32 in visual studio code.

Postby FRANCISCO2020 » Wed Jan 04, 2023 10:49 am

Hello, yes it is possible....But, But....

Make sure you're using the correct include paths – Arduino libraries will generally be located in a different location than standard C libraries, so you'll need to make sure you're using the correct include paths to find the Arduino header files. You can do this by adding the path to the Arduino libraries to the include path in your build system or by using the #includedirective with the full path to the Arduino header files.

Make sure you're linking to the correct libraries – If you're using functions from the Arduino libraries that are implemented in separate object files, you'll need to make sure you're linking to the correct libraries. This can usually be done by specifying the path to the Arduino libraries in the linker flags or by using the appropriate build system commands to link the libraries.

Make sure you're using the correct data types and function prototypes: Arduino libraries can use different data types and function prototypes than standard C libraries, so you'll need to make sure you're using the correct data types and function prototypes. correct functions when calling Arduino functions from your standard C code. You can usually find the correct data types and function prototypes in the Arduino header files.

If you're still having trouble mixing the Arduino libraries with standard C code, it might be helpful to consult the documentation for the Arduino libraries and the build system you're using to see if there are any additional steps you need to take.



regards

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: Using arduino libraries for ESP32 in visual studio code.

Postby bidrohini » Wed Jan 04, 2023 10:59 am

I think you can cross-check your steps with this tutorial: https://randomnerdtutorials.com/vs-code ... 6-arduino/
Errors may occur if necessary files are missing.

Who is online

Users browsing this forum: No registered users and 42 guests