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]

Edited 7 Years Ago by willgr: n/a

Attachments
<html>

<head>

<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-16">

</head>

<body>

<pre>

<table width=100% bgcolor=#CFCFE5><tr> <td> <font face=arial size=+3>

Build Log

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>

<h3>Build started: Project: libcurl, Configuration: Debug|Win32</h3>

</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>

Command Lines

</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Creating temporary file "c:\Users\will\Desktop\curl\curl-7.19.6\lib\Debug\RSP00000142485076.rsp" with contents

[

/Od /I &quot;.&quot; /I &quot;..\include&quot; /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_WINDOWS&quot; /D &quot;_USRDLL&quot; /D &quot;BUILDING_LIBCURL&quot; /D &quot;_VC80_UPGRADE=0x0600&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MDd /Fp&quot;.\Debug/libcurl.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /FR&quot;.\Debug\\&quot; /W0 /c /Zi /TC &quot;.\base64.c&quot;


&quot;.\version.c&quot;


&quot;.\url.c&quot;


&quot;.\transfer.c&quot;


&quot;.\timeval.c&quot;


&quot;.\tftp.c&quot;


&quot;.\telnet.c&quot;


&quot;.\strtoofft.c&quot;


&quot;.\strtok.c&quot;


&quot;.\strerror.c&quot;


&quot;.\strequal.c&quot;


&quot;.\strdup.c&quot;


&quot;.\ssluse.c&quot;


&quot;.\sslgen.c&quot;


&quot;.\ssh.c&quot;


&quot;.\splay.c&quot;


&quot;.\speedcheck.c&quot;


&quot;.\socks_sspi.c&quot;


&quot;.\socks_gssapi.c&quot;


&quot;.\socks.c&quot;


&quot;.\slist.c&quot;


&quot;.\share.c&quot;


&quot;.\sendf.c&quot;


&quot;.\select.c&quot;


&quot;.\security.c&quot;


&quot;.\rawstr.c&quot;


&quot;.\qssl.c&quot;


&quot;.\progress.c&quot;


&quot;.\parsedate.c&quot;


&quot;.\nss.c&quot;


&quot;.\nonblock.c&quot;


&quot;.\netrc.c&quot;


&quot;.\multi.c&quot;


&quot;.\mprintf.c&quot;


&quot;.\memdebug.c&quot;


&quot;.\md5.c&quot;


&quot;.\llist.c&quot;


&quot;.\ldap.c&quot;


&quot;.\krb5.c&quot;


&quot;.\krb4.c&quot;


&quot;.\inet_pton.c&quot;


&quot;.\inet_ntop.c&quot;


&quot;.\if2ip.c&quot;


&quot;.\http_ntlm.c&quot;


&quot;.\http_negotiate.c&quot;


&quot;.\http_digest.c&quot;


&quot;.\http_chunks.c&quot;


&quot;.\http.c&quot;


&quot;.\hostthre.c&quot;


&quot;.\hostsyn.c&quot;


&quot;.\hostip6.c&quot;


&quot;.\hostip4.c&quot;


&quot;.\hostip.c&quot;


&quot;.\hostasyn.c&quot;


&quot;.\hostares.c&quot;


&quot;.\hash.c&quot;


&quot;.\gtls.c&quot;


&quot;.\getinfo.c&quot;


&quot;.\getenv.c&quot;


&quot;.\ftp.c&quot;


&quot;.\formdata.c&quot;


&quot;.\file.c&quot;


&quot;.\escape.c&quot;


&quot;.\easy.c&quot;


&quot;.\dict.c&quot;


&quot;.\curl_sspi.c&quot;


&quot;.\curl_addrinfo.c&quot;


&quot;.\cookie.c&quot;


&quot;.\content_encoding.c&quot;


&quot;.\connect.c&quot;

]

Creating command line "cl.exe @"c:\Users\will\Desktop\curl\curl-7.19.6\lib\Debug\RSP00000142485076.rsp" /nologo /errorReport:prompt"

Creating temporary file "c:\Users\will\Desktop\curl\curl-7.19.6\lib\Debug\RSP00000242485076.rsp" with contents

[

/OUT:&quot;.\Debug\libcurl.lib&quot; &quot;.\Debug\base64.obj&quot;


&quot;.\Debug\connect.obj&quot;


&quot;.\Debug\content_encoding.obj&quot;


&quot;.\Debug\cookie.obj&quot;


&quot;.\Debug\curl_addrinfo.obj&quot;


&quot;.\Debug\curl_sspi.obj&quot;


&quot;.\Debug\dict.obj&quot;


&quot;.\Debug\easy.obj&quot;


&quot;.\Debug\escape.obj&quot;


&quot;.\Debug\file.obj&quot;


&quot;.\Debug\formdata.obj&quot;


&quot;.\Debug\ftp.obj&quot;


&quot;.\Debug\getenv.obj&quot;


&quot;.\Debug\getinfo.obj&quot;


&quot;.\Debug\gtls.obj&quot;


&quot;.\Debug\hash.obj&quot;


&quot;.\Debug\hostares.obj&quot;


&quot;.\Debug\hostasyn.obj&quot;


&quot;.\Debug\hostip.obj&quot;


&quot;.\Debug\hostip4.obj&quot;


&quot;.\Debug\hostip6.obj&quot;


&quot;.\Debug\hostsyn.obj&quot;


&quot;.\Debug\hostthre.obj&quot;


&quot;.\Debug\http.obj&quot;


&quot;.\Debug\http_chunks.obj&quot;


&quot;.\Debug\http_digest.obj&quot;


&quot;.\Debug\http_negotiate.obj&quot;


&quot;.\Debug\http_ntlm.obj&quot;


&quot;.\Debug\if2ip.obj&quot;


&quot;.\Debug\inet_ntop.obj&quot;


&quot;.\Debug\inet_pton.obj&quot;


&quot;.\Debug\krb4.obj&quot;


&quot;.\Debug\krb5.obj&quot;


&quot;.\Debug\ldap.obj&quot;


&quot;.\Debug\llist.obj&quot;


&quot;.\Debug\md5.obj&quot;


&quot;.\Debug\memdebug.obj&quot;


&quot;.\Debug\mprintf.obj&quot;


&quot;.\Debug\multi.obj&quot;


&quot;.\Debug\netrc.obj&quot;


&quot;.\Debug\nonblock.obj&quot;


&quot;.\Debug\nss.obj&quot;


&quot;.\Debug\parsedate.obj&quot;


&quot;.\Debug\progress.obj&quot;


&quot;.\Debug\qssl.obj&quot;


&quot;.\Debug\rawstr.obj&quot;


&quot;.\Debug\security.obj&quot;


&quot;.\Debug\select.obj&quot;


&quot;.\Debug\sendf.obj&quot;


&quot;.\Debug\share.obj&quot;


&quot;.\Debug\slist.obj&quot;


&quot;.\Debug\socks.obj&quot;


&quot;.\Debug\socks_gssapi.obj&quot;


&quot;.\Debug\socks_sspi.obj&quot;


&quot;.\Debug\speedcheck.obj&quot;


&quot

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]

Edited 7 Years Ago by willgr: n/a

>>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.

Edited 7 Years Ago by Ancient Dragon: n/a

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

Edited 7 Years Ago by happygeek: n/a

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.

This article has been dead for over six months. Start a new discussion instead.