Jimmy
Jimmy

Reputation: 12527

Using libcurl in C++ application

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.

Upvotes: 0

Views: 653

Answers (3)

Jose Palma
Jose Palma

Reputation: 756

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.

Upvotes: 1

dandan78
dandan78

Reputation: 13925

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.

Upvotes: 2

p01nt3r
p01nt3r

Reputation: 51

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.

Upvotes: 1

Related Questions