How to import libusb dll - c++

I am using Visual Studio 2013 and have troubles using libusb dll. I have downloaded their source and compiled the dll version under release. New folder was created: D:\libusb-1.0.9\Win32\Release\dll which contains the .lib and .dll files. The next thing I did, was copied the .dll to my Visual studio projects folder, where the source files reside.
In Visual studio I then did: project->properties->linker->input->additional dependencies and pasted in the path to .lib file: D:\libusb-1.0.9\Win32\Release\dll\libusb-1.0.lib. Then I did project->properties->linker->general->additional library directories and pasted in the folder where the libusb header files are: D:\libusb-1.0.9\libusb.
Then I tried including the #include "libusb.h" but it says it cant find the file.
What else do I need to do, to make it work...?
EDIT:
These are the exact errors:
Cannot open include file: 'libusb.h': No such file or directory
IntelliSense: cannot open source file "libusb.h"

The problem is you did not add the folder containing the header file libusb.h to the include folders for your compiler. As a result the compiler can not find libusb.h since it is not in any of the folders the compiler searches.
In Visual Studio to add a folder to the include directories open the project properties for your target and add the folder to the C/C++->General->Additional Include Directories setting.

Related

how to reference ssleay32.dll in visual studio c++ project

I am new to c++. I have creating a previous copy of the exe application and using the ssleay32.dll and libeay32.dll in visual studio 2017. I have added its path in the C++/General/Include directories and Linker/Input/Additional Dependencies and VC++/Include directories and added the dll in debug folder and current directory. but still cannot figure out what I am doing wrong.
I am unable to include the <openssl/ssl.h> in the cpp file in the project
Any help to fix it?
There is an example on the Microsoft Docs for reference.
project->properties->configuration properties->C/C++->General->Addtional Include Directories->add the path of dll
project->properties->configuration properties->Linker->General->Addtional Library Directories->add the path of dll
project->properties->configuration properties->Linker->Input->Additional Dependencies
For the header file, you could click Project—>Configuration Properties—>C/C++—>General and add the folder path where the .h file is located in the Additional Include Directories.

Boost Library cannot get to work in C++, Include directories not working

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

Cannot open source file "GL/glew.h"

I'm getting into OpenGL and Visual Studio, and just got this warning and couldn't find any possible solution. I've added both GLEW and GLFW Libraries to the include directory, and then again in the input section of the Linker menu, in the project's properties. Anyways, Visual Studio seems unable to find any of them.
See these images - they explain it all.
Include Directories:
Linker Input:
The Problem:
GLEW Directory:
GLFW Directory:
All image link together
It's because your include directories should be pointing to where the header files are, not the .lib files.
Change your include directory to go to where the .h files are located, for me it's C:\...\glew-2.0.0\include\GL
The directories you currently have in it should instead go into Additional Library Directories located at linker->general in your options

Cannot open source file in visual studio 2015

I am trying to compile OBS studio with this tutorial in windows using Visual Studio Community 2015. I have created a project in visual studio and copied the entire git repo into the project by dragging the files into the solution explorer. This project has dependencies on libav, x264, and curl. They are given as .lib, .dll, and header files.
The problem is I keep getting "cannot open source file". I have the the header files in a separate folder from the dll's and lib's (dll and lib are in the same folder). Under the project settings->VC++ Directories I added the include directory, and also added the library directory. Then I added the lib's specifically under Linker->input->additional Dependencies. Then I added the directory that contains the .dll files to the environment variable PATH.
After all this, I still keep getting the same error, as well as a few other errors. Here is a screen shot of one source file that has the issue.
These are my settings.
For the path, I have tried with and without the trailing forward slash.
EDIT:
Use the C/C++ settings instead of VC++ settings for additional include directories.
What is probably holding you up is that those folder icons in the VS sidebar are not actually related to the file system. They are filters and don't change depending on the actual directory.
This is another explanation for Drop's suggestion -- check to see if the files are really where you think they are.
In my case I already added the include libraries but that was not enough. The error went away once I switched the configuration from x86 to x64 in Project Properties.

Using pthread in c++ on Visual Studio 2013

I am trying to use the pthread library on windows. I downloaded a zip with a Pre-built.2 folder in it and followed the instruction.
What I have done so far:
all .h files from POSIX\Pre-built.2\includeinto MS VS2013\VC\include folder
all .dll files from \dll\x86dll\x86 into VC\bin
all .lib files from lib\x86 into VC\lib
In Property->Config->Linker->Input->Additional Dependencies, pthreadVC2.lib;pthreadVCE2.lib;pthreadVSE2.lib;%(AdditionalDependencies) // pthread.lib already in Inherited values
I included pthread.h inside my program and when trying to build solution, the following error appears:
Error 1 error LNK1104: cannot open file 'pthread.lib'
Can anyone help me out? Thanks.
EDIT:
The Include Directories and Library Directories are
A:\Program Files %28x86%29\Microsoft Visual Studio 12.0\VC\include;$(IncludePath)
and
A:\Program Files %28x86%29\Microsoft Visual Studio 12.0\VC\lib;$(LibraryPath)
respectively now. But I still get the same error message.
Add the folder containing the LIBs to Configuration Properties -> VC++ Directories -> Library Directories.