cURL with Visual Studio 2013 - c++

So i have came along with cURL as a very nice library and working very fine in OSX.
But on windows now i have got big troubles with getting ready with this library. I googled now for about 2 days and tried over a dozen (in detail) different ways to get this ready. Without any success at all.
Here are some ways I basically tried:
The direct Download: The problem here already starts with the right download. The official download page is pretty confusing, so i considered this "cURL Download Wizard" > "libcurl development" which gives me a version, that i should be able to include into any project. But how exactly to include it? In ANY instructions out there it leads me to directories i dont even have. Almost always this "curllib.lib" is mentioned. I downloaded about 6 different versions on that downloadpage, in none of them there is this file. (See for example this instruction)
Git + CMake: As a solution on the aboves Link there is suggested to use git clone on this. I did all the instructions there and also get the Projects generated with just warnings. But here it says as well:
After building install target, your will find bin/include/lib folders in C:\curl.vc12 Well, i did not really get his point of "build install target", i just build the entire project map as it comes. Compiles fine (115 succeeded, 0 failed, 2 skipped). But now C:\curl.vc12 is not there. What do i have to pre-setup before compiling this?
NuGet: The idea comes from the link in point (1) again, a different solution with NuGet.
With Successfully added 'curl 7.30.0.2' to test. it also seemed nice, but compiling simple.c leads to a bunch of unresolved external symbol linker errors. But a solution is provided:
Make sure the include directory and lib directory are specified under the Visual C++ directories in project properties.
So in Project > Properties > VC++ Properties > "Include Directories" and Project > Properties > VC++ Properties > "Library Directories" as well as in Project > C/C++ > General > "Additional Include Directories" and in Project > Linker > General > "Additional Library Directories" I desperately added the \packages\ path from my project folder.
As mentioned in the instructions, I added libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib; to Project > Linker > Input > "Additional Dependencies".
All that done, the unresolved external symbol errors are gone! Therefore I get just one error saying cannot open file 'libcurl.lib'. What can I do here?
I am pretty new to all that. But I am trying really hard now to get this finally to work. So what can I do?
I work with Visual Studio 2013 Community Edition. The currently most recent version of cURL is 7.42.1.
Any help is highly welcome!

Had problems myself, finally got it working now.
I downloaded curl-7.42.1.zip from the official website.
Within the archive you'll find the source code and winbuild/BUILD.WINDOWS.txt, which basically contains the instructions I followed. I'll assume that it has been unzipped to C:\curl-7.42.1.
Open the Visual Studio command prompt located at
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
This automatically sets the environment variables needed to use Visual Studio tools like the compiler. Then move to the winbuild directory and call
nmake /f Makefile.vc mode=dll
as described in the text file I mentioned above.
That will create the directory
C:\curl-7.42.1\builds\libcurl-vc-x86-release-dll-ipv6-sspi-winssl
containing libcurl.dll, libcurl.lib and the necessary header files. Let's rename it to C:\curl-7.42.1\builds\release :'D
Then open your project.
Open your project's properties.
Make sure you choose Release as configuration (top left corner)!
Navigate to VC++ Directories > Include directories and add C:\curl-7.42.1\builds\release\include
Add C:\curl-7.42.1\builds\release\lib to VC++ Directories > Library directories.
Go to Linker > Input > Additional Dependencies and add libcurl.lib.
Finally copy C:\curl-7.42.1\builds\release\bin\libcurl.dll to your project folder.
That should do the trick! :D If you want to use cURL in debug mode, you can do almost the same, recompile using nmake /f Makefile.vc mode=dll debug=yes, go to your project's properties, add the newly created directory paths (changing libcurl.lib to libcurl_debug.lib) and you should be done.

I had the same issue. I downloaded the curl from https://github.com/curl/curl. you can actually compile it directly with Visual Studio 2013 (but be careful with parameters setting: x64 with release). The major difference is that it gives you libcurl_imp.lib. Then all you have to do is to set the environment variables as described above. Just want to mention, you will have to use libcurl_imp.lib rather than libcurl.lib in the additional dependencies (I suspect this change is because of the new version of curl).

Related

How can I tell Visual studio where my additional .dll files are?

I have recently switched my IDE to Visual Studio 2019 for C++ projects. I easily followed a tutorial into setting up a new library like SFML into visual studio, and tell it where the additional include and library directories are.
But there is something else that is required for it to work, which are the .dll files. Every page I followed, even the Documentation by the SFML website, it says that they have to be in the same directory as my project. That means I need to copy-paste the 7-8 files into my project directory. This really makes the folder look untidy. I would like to create a new folder and tell Visual Studio where those files are. I tried going doing this
Project -> Properties -> Linker -> Input -> Additional dependencies
Usually, the lines that would work are
sfml-system-d.lib
sfml-window-d.lib
...
I tried doing $(ProjectDir)valid path\ sfml-files.lib but this gives me the linker error, saying that It could not find the file.
If I simply move the .dlls into a folder without doing anything, the code would compile and link fine. But when it runs, Windows gives me a pop-up box with the same error message.
Here is how it currently looks
Looks really messy, I just want to be able to move them into dependencies like how src contains the source files.
How can I achieve this?
As it is now, it works perfectly fine. The issue only occurs when I try to create a new folder.
I hope I have covered the important information required for a good answer, If not please let me know what more I should add
Microsoft Visual Studio 2019
Currently running 64-bit platform with Debug configuration. Hence the -d suffix
You could create a path environment for your specified directory, which is like drescherjm’s suggestion. The steps:
Right-click “This PC” -> “Properties”-> “Advance System settings”
Click “Environment Variables”
In the System Variables group, edit “Path”
Add your directory, for example: ”D:\ SFML-2.5.1\bin”
Restart your visual studio and re-open your project
The easier solution might be to put them in the x64 subdirectory. This allows you to have various builds side by side (x86/x64, debug/release).
Since this x64 directory is where the EXE is located, it is the first directory searched for DLL's. It will take precedence over the Path solution suggested in the other answer. The Path directories are searched last of all.

linking v8 to c++ application

I'm having trouble trying to get v8 working with visual studio 2019.
I have followed the compiling guide on v8.dev and built it on windows.
I have followed [this]Google V8 - Neither v8.dll nor v8.dll.lib getting built in release mode answer to obtain .dll and .lib files.
Now I'm stuck. I tried to build the examples they show on the official site (https://chromium.googlesource.com/v8/v8/+/branch-heads/6.8/samples/hello-world.cc) but I get all sorts of errors.
From what I understand, I need .dll, .lib and .h files. I have them, but I'm not able to use them correctly in visual studio.
I have tried adding the header files under include directories and .lib files under Linker > Input > Additional Dependencies without luck.
There are good chances anyone who has worked with c++ beyond simple console programs will laugh at my ignorance, and I would understand that.
Any help would be very appreciated.
UPDATE
These are the steps i followed to use v8:
1) Created a new c++ console solution
2) Added header directory at Configuration > C/C++ > Additional Include Directories
3) Added dll and v8.dll.lib folder in Configuration > Linker > Input > Additional Dependencies
4) Pasted this (https://chromium.googlesource.com/v8/v8/+/branch-heads/6.8/samples/hello-world.cc) code to my editor
The first type of error I got is E1696: it looks like some headers contain references to other headers with absolute paths and not relative paths.
I fix this by myself making reference paths relative in headers.
Then I get 23 LNK2019 errors:
screeshot
What should I do?

Boost C++ Libaries in Visual Studio 2017 C++ Project - "Cannot open include file"

I'm trying to add the Boost C++ Libraries to my C++ project created with Visual Studio 2017.
I have followed the instructions here.
When that didn't work I tried the advice in this post. Neither solutions worked for me.
What I have done:
Downloaded boost_1_69_0-msvc-14.1-64.exe from this precompiled boost libraries page
Installed to D:\local\boost_1_69_0
In my project I added D:\local\boost_1_69_0 to Properties > VC++ Directories > Include Directories and added D:\local\boost_1_69_0\lib64-msvc-14.1 to Properties > VC++ Directories > Library Directories
I have my project set to x64 and the above settings were set in the x64 configuration
When I try to build my project I get this error:
Error C1083 Cannot open include file: 'boost/regex.hpp': No such file or directory
Which points to this line of code in one of my .cpp files:
#include <boost/regex.hpp>
Please go to D:\local\boost_1_69_0 folder and see if you have a sub-folder named include in there. If you do, then instead of D:\local\boost_1_69_0 you need to set D:\local\boost_1_69_0\include in Properties > VC++ Directories > Include Directories
In other words, try to find the file you are including on your hard drive. Look at the full path to the file. Compare that full path with the path you added to the list of include directories (Properties > VC++ Directories > Include Directories) concatenated with the relative path you provided just before the filename in your include directive (boost). See if the two are the same.
If that does not help, then make sure you changed list of include directories for the same build configuration as you are attempting to build (if you build Debug, make sure you changed configuration for Debug too). Since VS 2015 IDE stopped making sure the two are selected in sync, which is annoying.
If your files are copied, then you have to compile the regular library.... If the same version of the compiler copies the machine.
Found out it was failing because I had included the same .cpp file which has the boost include into my unit test project which did NOT have the Include/Library folders set. The settings in my original question work now.

Visual Studio ignoring include directories

I am running Visual Studio Community 2017 and Windows 10. I have a project for which I have added an include-file directory under Project > Configuration Properties > VC++ Directories > Include Directories, but Visual Studio simply ignores the directory and will not find the include files. It finds the files if I hard-code the directory into the #include statement. I checked the .vcxproj file and the directory shows up there. I just updated/corrected Visual Studio to the most recent version and have since re-booted, but the problem remains. Help, please!
First, ensure that MFC is enabled in project properties > Configuration Properties > General
use of mfc must be set to static or dynamic library.
then to ensure that cl.exe is using all of the include directories that you specify, you need to go to project properties > c/c++ > general and change suppress startup banner to no /nologo.this will give you the full cl command for each source file, showing exactly what visual studio is attempting to do with the code and configuration options that you give to it.
Additional ideas for troubleshooting this kind of issue:
When using vs2015 you can try to add '#include <somenoneexistingfile.h>' to the top of any .c/.cpp and right-click on it to open a context menu and select "Open Document <somenoneexistingfile.h>. This will open a dialog showing you the actual paths being used for including. Note: This specific approach doesn't work with vs2019 or later.
Besides this, you can check if:
you edited the actual configuration (Debug/Release) which you are starting, i.e. maybe you only edited the additional-include-path for the debug-build but are trying to compile a release-build.
you edited the actual platform (x64 vs x86) which you are starting, i.e. maybe you only configured the additional-include-path for x86 but are trying to compile the x64 platform.

How to set up [ ZeroMQ ] for use in a Visual Studio 2015 Enterprise?

While my primary domain of expertise is not Visual Studio 2015 setup / project configuration, I have experienced troubles on loading / configuring ZeroMQ project.
How to proceed correctly on loading a ZeroMQ Project?
Observed errors:
current build on github and even old "stable" versions cause cmake errors
ZeroMQ Installer does not support Visual Studio v14
Instructions would be awesome, as it seems that there is no other source of documentation for this situation on the internet.
Had the same problem a while ago. Here is what I did to solve this:
Download the right ZMQ version
The "download link" provided on the ZMQ website seems outdated.
To really get the current version you would have to use Git:
git clone https://github.com/zeromq/libzmq.git
Build with Visual Studio 2015
The repository comes with a pre-build Visual Studio project. You can find it in ...\libzmq\builds\msvc. To build for Visual Studio 2015 cd into vs2015 and open libzmq.sln.
You can choose if you want to compile static or dynamic libraries: DynRelease or StaticRelease for either Win32 or x64.
After that, run Build > Build solution to compile everything.
Setup project to use compiled libraries
After you created your project, go to the project's properties:
C++ > General > Additional Include Directories should point to the include path of the repository. If you want to use C++ style some additional files have to be placed in this directory. Alternatively you can take a look at https://github.com/zeromq/zmqpp.
Linker > General > Additional Library Directories should point to the built libraries. They should be located at ...\libzmq\bin\x64\Release\v140\dynamic\.
Linker > Input > Additional Dependencies should contain the name of the library you want to use. The default should be libzmq.lib, otherwise you will find the name in the bin directory.
The program depends on the libzmq.dll file you just built. This file has to be placed within your project's build directory. To achieve this, you can add the following command to Build Events > Post-Build Event > Command Line:
copy /Y "...\libzmq\bin\x64\Release\v140\dynamic\libzmq.dll" "$(OutDir)"
This will copy the .dll file to the destination directory on every build if it's missing.
Hope this helps =)