Hello,

I am new to C++ but I have built an indexing app over the past 2/3 weeks using C++ Standard Library.

This went very smoothly but I now want for the first time to bring in an external library called libcurl.

I have attached a Build log which seems to indicate that I built it OK.

But I do not know how to use this library. Is it now 'installed'? If not, what further steps do I need to take? Can I now just put an 'include' at the top of any .cpp file as I do for the standard library?

As you can see I am quite clueless w.r.t. external library usage. [Visual C++/Windows Vista]

Hello,

I seem to be able to include the library by putting the following:

#include "curl/curl.h"

It is important to realise that the folder "curl" is the one contained in the "include" directory.

None of these files seems to have been produced by my building with Visual C++ so I think I could have just linked it in like that to start with (though I do not know this).

I also do not know whether this is the 'correct' way to link a library in (I mention it only because it works).

I got this approach from here.

Actually, sometimes I got errors like this after doing the above:

vardemo.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in funct
ion _main

The solution was to put "libcurl.lib" in the same directory as the C++ source file which I also added the following line to so it can see the lib.

#pragma comment(lib, "libcurl.lib")

The downloaded version of curl to use is Win32 - MSVC (SSL disabled - or else it will expect an SSL lib to be present).

So final DIR structure is

/C++ source file
/libcurl.lib
/curl/[stuff from include DIR from download, should include curl.h]

[also you dont need to build anything at any stage of this, just use files from the download]

>>The solution was to put "libcurl.lib" in the same directory as the C++ source file which I also added the following line to so it can see the lib.

That may be one solution, but not the best solution. The best solution is to tell the compiler where the library is located. How to do that depends on the compiler. If compiling from the command-line then more than likely you give it a -L <path> flag, such as g++ -L c:\libcurl\lib file.cpp -o a.out If you are using an IDE such as VC++ 2008 then add the library path to the Projects settings link tab.

Thanks for that, I do not know if I used the correct args (Visual C++, though I dont understand the GUI so I use Notepad++ with cmd line) but this also seems to work:

cl /EHsc vardemo.cpp /link C:\<DIR>\libcurl.lib

Thanks for that, I do not know if I used the correct args (Visual C++, though I dont understand the GUI so I use Notepad++ with cmd line)

You should take the time to learn so that you can program more efficiently and easier. You are currently using 50-year-old technology (command-line build).

How to create a project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.