How to add libusb in Microsoft Visual studio 2013 - c

I am using Microsoft Visual Studio 2013, how can I add the external library libusb to my project?

libusb will contain a LIB file, DLL file and header file. You will need to include the libusb header file in your source project. Then under your project settings you should go to the Linker section and add the LIB file as a linked object. Then, just ensure your DLL is accessible to your executable when running or debugging.

Related

import libssh library in Visual Studio 2017

I'm currently trying to include the libssh library on Visual Studio 2017.
I already downloaded libssh but I don't know exactly what am I supposed to do with cmake. Where should I include files in Visual studio?
What you downloaded is the source code of libssh. So before you can link it to any of your own projects, you need to build libssh first. This were cmake comes in. CMake is the build system used for libssh.
In the source tree, which you have downloaded, you will find a file named INSTALL. It contains descriptions about all the prerequisites and a how you can use cmake to build libssh yourself.
If you prefer it, you can alternatively download a prebuilt version of libssh from https://www.libssh.org/files/win32/0.5/. The downside is, this is a quite dated version.
You can use vcpkg to download C++ libraries like libshh through command prompt. In this way the required dll's will be automatically include in your project directory, once you include the related header file in your project and compile it. See https://www.libssh.org/get-it/.

How to make VC 2015 generate a DLL and not just a lib file?

I'm building SDL_pnglite from source, in Visual Studio 2015. I've gone through and added references to the proper .h and .lib files for its dependencies (zlib and SDL2), and I set Configuration Properties->General->Project Defaults->Configuration Type to DLL.
When I build, it builds successfully, but it only generates a .lib file and not a .dll. What am I missing? In the past, all I've ever needed to build a .dll was that Configuration Type setting, but this time it's not working.

Visual Studio 2010 error linking Winsock library (C)

I'm trying to build a C server program, and I keep getting these errors:
http://i.imgur.com/cavkPAF.png
The common fix I'm seeing is to link to ws2_32.lib, which I'm doing already(Properties > Linker > Input > Additional Dependencies). I've also included WinSock2.h. I have the windows sdk, and I get no errors saying it can't find ws2_32.lib. I've tried linking directly to the .lib in the windows sdk directory, but still have the same problem. The dll is in correct place (C:\Windows\SysWOW64), and the SysWOW64 directory is listed in Configuration Properties > VC++ Directories > Executable Directories.
I have the same problem with Visual Studio 2013
Any ideas? Thanks.

How to link against .a files in Visual Studio 2012?

I have some static libraries in the form of .a files, and accompanying header (.h) files. How can I tell the linker Visual Studio 2012 Windows Desktop Express to reference these files so that I don't get "unresolved external symbol" errors when I try to build?
Include the .h header files, and make sure they are present in your project
Go to Project Properties > Configuration Properties > C/C++ > General > Additional Include Directories and add the path to the include directory where your header files can be found
Go to Project Properties > Configuration Properties > Linker > General > Additional Library Directories and add the path to the lib directory where your .a files can be found
Go to Project Properties > Configuration Properties > Linker > Input > Additional Dependencies and add the .a file accurately
Apart from this make sure you are in the correct configuration platform while building (x86 vs x64) and it is same as the one your library uses.
As far as I'm aware, you can't. They're usually using a different internal binary format the linker won't be able to understand. In a similar way, MinGW won't be able to use Visual Studio's lib files (except when using an additional tool to convert them).
You'll have to recompile the library from source or obtain library files that are compatible with Visual Studio.

Cannot include certain header files using the Visual C++ compiler

Hello I'm getting into Winsock programming in C. I believe that in order for me to access the (or any other header related to Winsock for that matter) header file I have to have Visual C++ 2010 installed and set it as my default compiler. So I download it, and in CodeBlocks I set it to my compiler. I run some Winsock code and I get this message:
C:\Users\Jared\Documents\Test.c|6|fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory|
I also get this message for including 'winsock.h' and 'windows.h'. This has something to do with the Visual C++ compiler. I try installing Visual C++ 2008 and use it as my compiler and get the same message. I then read that I have to install microsoft's SDK. I download and install it and it gets an error saying that I can't install it (this is the .Net framework 4.0 version). I then try the 3.5 version and it installs fine but my compiler still can't find the header files. I have the .net framework 4.0 so I don't see the problem. I also read that I have to include some header files in Visual C++ by going to Tools>Options>Projects and Solutions>VC++ Directories and I get the following message:
"VC++ Directory editing in tools > options has been deprecated."
Visual C++ 2010 no longer supports this feature. Does anyone have a solution or can help me with this?
Long story short: I cannot include 'winsock.h', 'winsock2.h', or 'windows.h' using the Visual C++ 2010 compiler.
All help is appreciated.
In Visual C++ 2010 it is recommended to use property sheets instead of this kind of global directory settings editing. You need to edit the user settings property sheet (probably Microsoft.Cpp.Win32.user.props) in your AppData folder. You can do it in the UI through the Property Manager via View->Property Manager and browsing for that sheet.
However, I think you should have $(WindowsSdkDir)include in Include Directories if you have it installed correctly.

Resources