0

I'm new to C++ but I'm having a hard time working out how to use libcurl with a c++ program.

A) Should I install libcurl with apt-get for the server or install it as some sort of library in C?

B) What is the point of using a c++ binding for libcurl, can I not use it directly without a binding? https://github.com/JosephP91/curlcpp

Sorry if this is obvious.

3 Answers 3

2

You need a library to link to. Not quite sure whether apt-get provides that, but checking the project website will probably turn up a download link. Alternatively, you can build the lib from source.

As for the C++ wrapper, you are correct in that you don't need it. It was probably written for the sake of keeping things object-oriented and perhaps to add some convenience. Otherwise you can use it the old C way without any problems.

Sign up to request clarification or add additional context in comments.

Comments

1

For commodity sake, always is easier to install with the apt-get/yum or the install system you use in your OS.

A) In my company we have it compiled on one folder. In my house I usually install it from official repositories, I find it easier but it depends if you want to distribute your product and keep your code fixed with one version.

B) That's always up to you, I usually use it directly, I prepare my own eventing system(kqueue/epoll or using libuv/libev/libevent/asio), and assign the callbacks.

2 Comments

If I install it with apt-get as you say do I just use it as if I had included the header?
Yes and you must not forget to include in the linker the libcurl -> usually -lcurl for example g++ -o sms ./src/sms.o -lcurl
1

A) you have to have the lib installed in your SO's. Otherwise you cannot link it in the program.

B) part1: The point of c++ binding for libcurl, it's for allow you do:

#include "curl_easy.h"

Otherwise you would not be allowed to do it, without implement by yourself the curl_easy.h, remember that it has only C api interface (taken by homepage of libcurl), it allows you to use it because its C but not in native mode. B) part2: yes you can, but you will need to use the C version of the libcurl. Not the C++ version like you do by the biding.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.