Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building under Windows via Visual Studio #11

Open
JTD420 opened this issue May 29, 2022 · 5 comments
Open

Building under Windows via Visual Studio #11

JTD420 opened this issue May 29, 2022 · 5 comments

Comments

@JTD420
Copy link

JTD420 commented May 29, 2022

The link provided to the fork of build-libcurl-windows is no longer available ( : https://github.com/ribtoks/build-libcurl-windows )

How would one build libcurl under Visual Studio 2017 as per the requirements of this project without the aforementioned git repo?

Please can you provide an updated guide for Windows Users wishing to include your HttpClient in their C++ appliations?

Many thanks in advance!

@embeddedmz
Copy link
Owner

Hi,

I recommend you to use vcpkg https://github.com/microsoft/vcpkg and even in your other VS projects.

In another repo, I wrote instructions related to vcpkg : https://github.com/embeddedmz/ftpclient-cpp

Best regards.

@embeddedmz
Copy link
Owner

I have to fix the CMakeLists.txt files, I'm working on it right now.

@JTD420
Copy link
Author

JTD420 commented May 29, 2022

Brilliant! Thank you for the fast response. I have recently started using vcpkg but I wasn't sure how to use it to install this project. I'll take a look at your instructions for the ftpclient and see if I can figure it out!

Will I need to wait for you to fix the CMakeLists.txt files before it will work with vcpkg or is that just if I try building it from source?

Thanks again for the help!

@JTD420
Copy link
Author

JTD420 commented May 29, 2022

Followed your steps as per your instructions on your other repo and seems to have worked as I buit all_build and it said it was successful but I don't think I'm sure how to use this in my project?

if I #include "HTTPClient.h" I just get an error saying it can't open the source file so I presume I haven't finished the install properly?

@embeddedmz
Copy link
Owner

embeddedmz commented May 29, 2022

You have also a CMake option SKIP_TESTS_BUILD that you can set to false to have a unit test project in the solution generated by CMake... You can set that project as the startup project, indicate a path to an INI configuration file (read the README) and launch the unit tests program to check if everything is OK (tests using HTTPS might fail if curl[openssl] is not installed with vcpkg).

If you want to use the class in a project you have 2 options :

  • use the 2 header files and the generated static library in your application (copy also libcurl DLLs that have been copied in the build output directory by vcpkg/Visual Studio).
  • if your project already uses CMake, I think you can use the add_subdirectory (and maybe include_directories too if the scripts I have written are not compliant with the modern way of writing CMake scripts) to tell CMake to include httpclient-cpp to your future solution and then tell CMake to link your application to the library with target_link_libraries (With TestHTTP, the unit tests program of this class, you can see the I made the link with target_link_libraries(test_httpclient httpclient gtest ${CURL_LIBRARIES})

Otherwise, you can add all the files under the HTTP directory (HTTPClient and CurlHandle classes) in your VS C++ project and it should work too since you are using vcpkg (you must enable integration in VS before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants