import libssh library in Visual Studio 2017 - c

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/.

Related

installing GSL library for C programming in windows

I want to install the GSL library (https://www.gnu.org/software/gsl/) in windows. I have downloaded the files but i do not know what to do apart from that in order to be able to use the functions of the library (apart from the #include <...> in my program.c file).
I am using visual studio code and i have installed mingw.
Thanks in advance
EDIT
I am adding more information about this issue. I am not the original poster, but I have the same problem.
I am trying to use the GSL and I work with Visual Studio Code on Windows 10.
I have already installed the basic packages to work with C/C++ in
Visual Studio Code. More precisely, if I am not wrong, VS Code is
using the compiler gcc.exe from mingw64 (last version). This was
installed using an 'extension' available at VS Code (https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).
I downloaded the last version of the GSL (2.7) and unzipped it.
I get stuck when I try to follow the installation instructions. When I
execute either .\configure or ./configure in the DOS command line,
I get an error of "unknown command" (even if I am placed in the same directory where the file is stored).
When I execute .\configure in PowerShell, I get a message asking me
which programme should be used to open this file.
And here is where I get lost. :/
I have discovered an alternate path, which is installing GSL from vcpkg (https://vcpkg.io/). This is suggested by VS Code, actually. This vcpkg seems to be a programme by Microsoft to make it easier to install third-party C/C++ packages in Windows.
The specifications to install vcpkg are (https://vcpkg.io/en/getting-started.html):
Windows 7 or newer
Git
Visual Studio 2015 Update 3 or newer
I can try this path, but first I would like to be sure there is no easier way (installing Visual Studio to not really use it seems a lot to me!).

VS2017 Nuget pthread LNK1120 unresolved

I heard that Nuget builds project easier without any configuration.
So, I am trying to add pthreads in my project from Nuget
(Actually I am using windows 10 x64 Visual studio 2017, C language, and my friends use linux OS)
I just search pthreads in Nuget package, click "install" button
But, my project compiles well but fatal error LNK1120 called.
Is there any more configuration after install pthreads from nuget?
The reason why I ask this simple question in stackoverflow is that, there is no more steps in Microsoft official guides.
Is there any more configuration after install pthreads from nuget?
Using Nuget format to install pthread into C++ projects is quite simple and will not manually configure include Directories and additional Dependencies address any more.
But pthread nuget package in VS has a drawback that it does not fully inherit pthread class library. It lost a file called pthreadvc2.lib. You can try my following suggestions to configure it without any settings in project properties.
Solution
1) download pthread-w32-2-9-1-release.zip from this link.
2) unpack this file and then copy pthreadVC2.lib from the file(pthreads-w32-2-9-1-release\Pre-built.2\lib\x86 or x64) into
C:\Program Files (x86)\Microsoft Visual Studio\2017\xxxxx\VC\Tools\MSVC\xxxx.xx.xxxx\lib\x86 or x64.
Note that you should copy the related lib into the related folder, x86 pthreadVC2.lib into x86 folder, x64 pthreadVC2.lib into x64 folder.
3) then add this into your cpp file:
#pragma comment(lib,"pthreadVC2.lib")
Then it will work as expected without any errors.

C++ Library Package Manager for Clang/LLVM

I'm using Visual Studio 2017 as my IDE. I've set the "Platform Toolset" option (right-click the project and select "Properties". Then go to Configuration Properties > General) to be "LLVM-vs2014_xp" which is Clang/LLVM. This is in-place of the standard Visual Studio 2017 toolset which uses the MSVC compiler.
Now, before I was using vcpkg to handle installing C++ libraries for the MSVC compiler, and it was quite simple. If I wanted to install Boost, msgpack, Modern JSON for C++, and a variety of other C++ libraries, I just had to type in the terminal:
vcpkg install boost
Or equivalent. And my libraries would be found if I included the appropriate header in source code.
Now that I have switched to Clang/LLVM, when building in Visual Studio the Clang compiler can't find the same libraries. I am trying to avoid manually telling the Linker where certain things are/editing the Path variables like "Include Directories" and "Library Directories".
Does anyone know of an equivalent package manager to vcpkg for Clang?
Alternatively, if you know of a way to tell Clang to look for the vcpkg libraries that is simple, that is fine as well. I have already tried setting the "Include Directories" and "Library Directories" to the same values as for when Visual Studio toolset is set, with no luck.
EDIT: It now occurs to me that it might be possible to solve this by copying all tab values from "VC++ Directories" for when Visual C++ (MSVC) is the toolset to when Clang is the toolset. I may attempt...
EDIT 2: Do not attempt the edit above i.e. copying those tab values from the Visual C++ toolset properties. It just creates a bunch of linker errors...
Set the following under Configuration Properties>VC++ Directories:
"Include Directories" to include "C:\Program Files\vcpkg\installed\x86-windows\include"
and
"Library Directories" to include "C:\Program Files\vcpkg\installed\x86-windows\lib"
This links the vcpkg libraries and header files to the Clang/LLVM toolset!
Your directories might be in different locations so just set the paths appropriately for your setup.

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.

How to build gnu `libiconv` on & for windows?

I want to build a static library (*.LIB file) GNU libiconv on windows to be used with other libraries in Visual C++. Other libraries I'm using are built with "MultiThreaded DLL" (/MD) Runtime option. So, I need to build libiconv with the same option.
Problem is the libiconv uses GNU build system and I want to compile with /MD option. You can see the source structure of libiconv here:
http://cvs.savannah.gnu.org/viewvc/libiconv/?root=libiconv
Mr. Zlatkovic maintains the windows port of GNU libiconv for libxml2
you can see them here:
ftp://xmlsoft.org/libxml2/win32/iconv-1.9.2.win32.zip
I cannot use his port. I need to build from the latest version of libiconv-1.13. I wonder how this guy has ported it? Can some one please tell me how to build *.lib from this and compile it using MSVC?
EDIT:
Actually, I need to build few more gnu libraries with same settings. So, if I get solution for one library. I can do the same for all others.
I found PARK Youngho's How to Build libiconv with Microsoft Visual Studio over at The Code Project to be complete and clean (for VS2010 and GNU libiconv 1.14).
A little addition to your answer.
I had the same issue and found that the MinGW + MSYS solution was perfect.
Though, I needed to go a little further and generate also the .lib file in order to be able to link with the resulting dll.
This is what I found:
generate a .def file from the dll with dumpbin (a Visual Studio tool).
generate the .lib file from the .def with the lib program (Visual Studio tool too)
This allows you to specify some link flags if appropriate.
Everything detailed here (I'm not the author of this method):
http://wiki.videolan.org/GenerateLibFromDll
I also realized that this lib/dll couple can be linked with both MD and MDd libraries.
Hope that can help people that find this post, like it helped me.
-David
I'm the OP. MSYS is the exact thing what I was looking for.
Just install MinGW & MSYS which contains shell sh.exe & make.exewith which you can configure and generate a Makefile after that you can use make.exe to run it.
Its as simple as that.
compile them using MinGW using Msys for the environment if needed. MinGW's .a files are apparently, according to the mailing list, the same format as .lib files (just do a rename). You might want to check first to see if the iconv static library is included already in the MinGW download / filesystem.
Edit: it's in msys (C:\msys\1.0\lib), along with:
libiconv.a
libiconv.dll.a
libiconv.la
and additionally
libiconv-2.dll (in C:\msys\1.0\local\bin)
Edit: is it in here, the libiconv you need? these versions seem to have MSVC makefiles :) http://www.opensource.apple.com/source/libiconv/

Resources