Installing C++ libraries for VSCode - c++

I'm kinda new to programming in C++ and programming in general and I have a question regarding the installation and use of libraries, specifically in the context of VSCode. I am using the code that someone has given me for a project, but I don't have any of the libraries downloaded that they are using. These are some of the libraries I need access to:
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h>
When I search them up to download them, the common thing I found for them was the code for them through github. My questions really are how to I download these libraries and when I download them where do I save them on my computer so that I can use them for VSCode and for my projects?

Related

Standard libraries still require additional runtime libs? (vcruntime140_1.dll)

I've created a Windows x64 program using standard headers and DirectX (see below). I was kinda expecting no additional runtime libs would be required for the users. But i got the feedback from some that the vcruntime140_1.dll was missing. It's an easy fix, but how do I ensure that users don't need to download additional runtime libs besides DirectX?
#include <Windows.h>
#include <d2d1.h>
#include <dwrite.h>
#include <wincodec.h>
#include <TlHelp32.h>
#include <iostream>
#include <chrono>
#include <string>
#include <cstring>
#include <tchar.h>
#include <vector>
Running programs under Windows10 developed in Visual C++ require the associated runtime redistributables: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads.
Microsoft has decided to include the universal C Runtime (CRT) libraries with the standard Windows 10 installation and these are kept up to date via the general Windows update mechanism. The Visual C++ redistributables rely on these UCRT but require a separate installation. Installing the Visual C++ runtime libraries will also verify the latest UCRT are installed in case the user hasn't updated Windows regularly. More details are found on MSDN.
Another option would be include the libraries in the executable using static linking. The program will become larger and care should be taken they are included multiple times. Also any fixes by Microsoft to the dll's will require a rebuild of the program.

Check library version from third party code

I have code that was implements the OpenCV library, however, I do not know what version of the library it was written with. Is there anyway to find out from the code what version of the library that it was intended to be used with?
The only references to the library in the code is:
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/opencv.hpp"
There is no way to know for sure given that limited information, unless perhaps if you can run ldd and strings on a built executable you have. But I suggest that OpenCV 2.4.11 is very likely to work with what you have.
OpenCV was designed to be backwards compatible within every major version, that is the latest 2.X.Y revision should support any code written in version 2.X.Z. Since version 3.0.0 was released, any 2.X code may need to be reworked. This guy explains how to check version using code.

Dev-C++ cannot find <iostream> or <iostream.h> header files

Dev-C++ cannot find the I/O stream header files. I tried it with both #include <iostream> and #include <iostream.h> but I get the following errors.
[Error] iostream.h: No such file or directory
[Error] iostream: No such file or directory
What can I check in the Dev-C++ settings to make sure it's properly configured to build programs that use the C++ Standard Library?
#include <iostream>
You've got a double 's' in your code as far as I can see and that may be causing a problem. If including "iostream" header file won't work as well it means that your Dev-C++ (sic!) is probably not linked with MinGW properly.
As the others said, consider using f.e. Code::Blocks instead Dev-C++.
If you didn't download the Dev C++ that includes MinGW then you don't have the standard libraries. If you do have the standard libraries you will need to make sure to set it up by pointing it to the location of the source on your system.
If you still need the standard libraries, you can go to "Downloads" section of this page and go to the first link which includes MinGW.
But your best bet is to send Dev C++ off to die in a fire. The incredibly powerful Visual Studio 2015 is out and the Community version is free: https://www.visualstudio.com/downloads/download-visual-studio-vs There's really no excuse for using anything else on Windows.

How to use C Libraries for Arduino code

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

Setting up Opengl for Borlandc++

I have copied the glut.h file in c:/turbo/tc/include/ directory and glut32.dll in c:/windows/System32/.
After this what should I do ?
your path implies old Borland Turbo C++ 3.1 to me
which was the old MS-DOS C++ IDE (similar to Borland TP 7.0 pascal IDE)
in which you can not have classic 32bit OpenGL
there were some 16bit MS-DOS versions of GL+GLUT compatible ports of glut+gl libs.
so unless you do not have them then it will not work no matter you do
if you do then read the provided readme.txt or whatever to see how to use it
there were some tutorials on them but I strongly doubt you will find them on the internet
because most of old programing portals is off-line and stuff lost forever ...
if you have newer compiler like Borland C++ BCC 5.0 or newer
then just include headers
link lib files for used dll's for example:
#include "my_GL_headers\\glut.h"
#pragma link "my_GL_headers\\glut.lib"
use implib tool if you do not have them or are incompatible
because most provided libs are for MSVC++
which are incompatible with standard Intel object format
for more info see difference between COMF and OMF
some header files already link their lib files so do this only if you have unresolved externals ...
If you use IDE like Borland C++ builder 1,2,3,4,5,6 or Developer Studio 2006 Turbo C++
then look at this answer of mine: How to render an openGL frame in C++ builder?
all the headers and libs are included in IDE ...
PS this is how mine usual GL includes look like in BDS2006 projects
#include <windows.h>
#include <jpeg.hpp>
#include <math.h>
#define GLEW_STATIC
#include "gl\glew.c"
#include "gl\gl.h"
#include "gl\glu.h"
#include "gl\glext.h"
#include "gl\wglext.h"
#include "gl\glut.h"
where gl is project source local folder
including all headers/objs/libs ...
the only lib you need is glut.lib (if you want to use glut)
GLEW can be either as lib/dll/obj or as C++ source code
I prefer the C++ source version under borland/embarcadero