[QT] How do I use curlcpp with QT?

Hello,

I'm about to make my first legit application which actually does something useful.

But I'm not familiar with libraries such as curlcpp at all, so...

How do I connect curlcpp with QT and where do I have to include the headers etc.?

Where do I have to put the files of the Github to?

I haven't found any tutorial really explaining all that but I'd be really glad if someone could help me out. It seems like coding with libraries is the only fun thing to do but I just don't know how...

My program is supposed to let you insert a link and then it gets the source of that website and it searches for a specific tag and gets information from it but that's not really important now.

Thanks in advance
Theoretical adding a library is trivial:

- add the includ path to the project settings
- add the library to the project settings

but you might need to compile the library first. There you need to consult the documentation how to do it.

Appart from that adding a library has nothing to do with QT (which is itself a library). #include the header and use it as needed.
My program is supposed to let you insert a link and then it gets the source of that website and it searches for a specific tag and gets information from it but that's not really important now.

Is is really necessary to use curlcpp ? I am not a Qt guy but I guess that Qt has some functionality for such a ordinary task.
Qt has an API to do things like that; you can take a look at QNetworkAccessManager: http://doc.qt.io/qt-5/qnetworkaccessmanager.html
@coder777:

I've been looking at, as I'd say, everything but I haven't found a way to connect the library to QT.

"#include the header and use it as needed." But before including the header, doesn't the whole library has to be included?

@Thomas1965:

libcurl got recommended but I can only do c++ so I use curlcpp and I don't use QT for a long time yet so I don't know what is available to me by now.

@TwilightSpectre

How do I know which functions I need to use?
My program is supposed to let you insert a link and then it gets the source of that website and it searches for a specific tag and gets information from it but that's not really important now.
What you want to do is actually the most important information - IMHO

Under Windows you can use the URLDownloadToFile function to download the website. Then you can just use the normal ifstream and string - no need for any library.

https://msdn.microsoft.com/en-us/library/ms775123(v=vs.85).aspx
@Thomas:

I don't think so. What I want is: http://prntscr.com/bgr51e

The blue marked url but I want it to be automated so if I enter the website e.g.

youtube.com/watch?v=<video>

I get the requested URL (blue marked)

That's what I want... insert website, get video link
Last edited on
Read the 'detailed description' part to get a good overview. It includes examples of how to it. Or... google it; this is such a common task that there are sure to be examples of people using it online.
I've been looking at, as I'd say, everything but I haven't found a way to connect the library to QT.
Because there is none.

But before including the header, doesn't the whole library has to be included?
Two things: The project needs to know where to find the header and where to find the lib. If you provide this information you can use the library. That's it.
I haven't found a way to connect the library to QT.


That makes no sense and as such makes me wonder what you think "QT" is? If you tell us what you think QT is, we can tell you where you're going wrong.
Then add <curlcpp root>/build/src/ to your library path and <curlcpp root>/include/ to your include path.

When linking, link against curlcpp (e.g.: g++ -std=c++11 example.cpp -o example -lcurlcpp -lcurl). Or if you want run from terminal,

g++ -std=c++11 example.cpp -L/home/arun/path/to/build/src/ -I/home/arun/path/to/include/ -lcurlcpp -lcurl

https://github.com/JosephP91/curlcpp

Basically you add these lines to your .pro file,

QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += /home/arun/path/to/include/
LIBS += -L"/home/arun/path/to/build/src/" -lcurlcpp -lcurl

Of course with those paths being the real paths to those files on your system.

http://doc.qt.io/qt-5/third-party-libraries.html

Last edited on
Topic archived. No new replies allowed.