I have a code in Visual studio that I want to implement in Arduino. But there is a problem. Many libraries usable in Visual Studio aren't usable in Arduino IDE. How can I use them in my Arduino code. To be precise, the libraries I want to use are
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include <math.h>
#include <ctime>
respectively.
Okay so I know I have <iostream>
available in Arduino. <math.h>
is also available I think along with <string>
library.
The main problem is to how to use #include <queue>
and its functions such as priority_queue()
and other fucntions of iostream
like .pop()
?
2 Answers 2
Arduino behind the scenes is using the avr-gcc compiler, which provides support for many of the features of the C++ language. It does not, however, include an implementation of libstdc++, which means that a lot of the libraries and features you are used to having with other development environments are just not there. A big reason for this is that it is just not practical to implement some of that functionality on a small microcontroller.
There are several libraries available that implement simplified versions of some of the functions and data structures you are wanting to use. You can find a list (but not necessarily a complete one) of these libraries here:
http://playground.arduino.cc/Main/LibraryList
For example QueueList might be a good alternative to <queue>
.
Whatever you find, you are likely to have to refactor your code to use them. When you run into problems implementing those libraries and changes, I would recommend heading over to https://arduino.stackexchange.com/ to get more arduino specific answers.
-
Thanks alot jack C that was really helpful, I'll update you once I implement them on my arduino codeAZ123– AZ1232015年07月09日 10:24:23 +00:00Commented Jul 9, 2015 at 10:24
It is detailed over here:
https://www.arduino.cc/en/Hacking/BuildProcess
The include path includes the sketch's directory, the target directory (/hardware/core//) and the avr include directory (/hardware/tools/avr/avr/include/), as well as any library directories (in /hardware/libraries/) which contain a header file which is included by the main sketch file.
And these are the libraries supported by avr-gcc (the compiler that Arduino uses)
#include , #include , #include , #include , #include , #include
. You may want to edit your question to include the actual header file names.