0

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()?

πάντα ῥεῖ
88.8k13 gold badges125 silver badges198 bronze badges
asked Jul 8, 2015 at 20:19
10
  • Libraries you want to use: #include , #include , #include , #include , #include , #include. You may want to edit your question to include the actual header file names. Commented Jul 8, 2015 at 20:20
  • You can not. Just read an intro into Arduino. Also note that the Arduino language is neither C nor C++, so the tags are wrong here. Commented Jul 8, 2015 at 20:23
  • @rost0031 You were just blinded by inappropriate formatting. Commented Jul 8, 2015 at 20:43
  • Are you trying to access C language libraries from C++? Your question title asks about C libraries by the language tag is C++. Commented Jul 8, 2015 at 20:43
  • @OP Not these aren't different libraries, but header files bound to the c++ standard library implementation, that's coming with your c++ compiler. Commented Jul 8, 2015 at 20:44

2 Answers 2

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.

answered Jul 8, 2015 at 22:10
1
  • Thanks alot jack C that was really helpful, I'll update you once I implement them on my arduino code Commented Jul 9, 2015 at 10:24
1

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)

http://www.nongnu.org/avr-libc/user-manual/modules.html

answered Jul 8, 2015 at 22:03
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.