I’m a mac user, when it comes to generic libraries I love to
One day a buddy (a fellow Mechanical Engineering guy) comes up with a windows laptop and he needs help with a VC++ win32 project which is supposed to make http calls to rotate a servo (fancy :>). Well one has to save his pride. So after lot of fiddle here’s how I did it on visual studio 2013 (shall work in similar way for others as well).
Clone this repository blackrosezy/build-libcurl-windows and go to the cloned directory and run build.bat.
This should build the library for any version of visual studio you have automatically. Although the README explicitly says All version of Visual Studio express are unsupported. Now you have built header files, library files and dlls in the third-party directory. It shall look like:
third-party └───libcurl ├───include │ └───curl │ curl.h │ curlbuild.h │ curlrules.h │ curlver.h │ easy.h │ mprintf.h │ multi.h │ stdcheaders.h │ typecheck-gcc.h │ └───lib ├───dll-debug-x64 │ libcurl_debug.dll │ libcurl_debug.lib │ libcurl_debug.pdb │ ├───dll-debug-x86 │ libcurl_debug.dll │ libcurl_debug.lib │ libcurl_debug.pdb │ ├───dll-release-x64 │ libcurl.dll │ libcurl.lib │ libcurl.pdb │ ├───dll-release-x86 │ libcurl.dll │ libcurl.lib │ libcurl.pdb │ ├───static-debug-x64 │ libcurl_a_debug.lib │ ├───static-debug-x86 │ libcurl_a_debug.lib │ ├───static-release-x64 │ libcurl_a.lib │ └───static-release-x86 libcurl_a.lib
Now it’s time to add this to your VC++ win32 project. Create a new project or go to the existing project and follow these steps:
- Go to Project | Project Properties | VC++ Directories | Include Directories | Add the path to the include directory inside the third-party folder. (./third-party/include).
Note: do not add /third-party/include/curl as most of time it’s included as curl/curl.h in code.
- Next, go to Project | Project Properties | Linker | General | Additional Library Directories | Add the path to the lib directory. (Where libcurl_debug.dll is located). As my project was for x86 architecture I added ./third-party/lib/dll-debug-x86
- Then, go to Project | Project Properties | Linker | Input | Additional Dependencies | And add libcurl_debug.lib
- Now build the project, you can use this test code:
Note: If it throws error like libcurl_debug.dll is missing, it’s because the compiler is unable to find the dll file. Copy the libcurl_debug.dll file from /third-party/lib/dll-debud-x86 to the debug directory of your visual studio project and try to build again it should work.
This should give output as some HTML code.