curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: getting libcurl to run with C in codeblocks (mingw-32)

From: Greg Saunders <gmsaunders_at_gmail.com>
Date: Thu, 1 Dec 2016 11:09:43 -0600

Thanks, Daniel- that got me going in the right direction and I was able to
get it running. There were lots of little gotchas and false starts, so to
help others here are the steps I used, along with errors I encountered
along the way:

   1. download curl from https://github.com/curl/curl (note that this has
   to be set up as a git repository locally rather than just downloading the
   files, otherwise step #2 below will not work)
   2. run buildconf.bat
   3. run mingw32-make.exe mingw32
   4. create new C project in codeblocks (main.c)
   5. copy contents curl/docs/examples/url2file.c
   <https://github.com/curl/curl/blob/master/docs/examples/url2file.c>
   intro main.c for my test program
   6. run program- gives error: "curl/curl.h: No such file or directory"
   7. Under "Project/Build Options/Search directories/Compiler tab" add
   relative path to "myCurlGitDownload\curl\include\" (the .h files).
   8. run program - gives error: "undefined reference to `curl_global_init'"
   9. Under "Project/Build Options/Linker Settings", add "libcurldll.a"
   (from curl/lib/ folder)
   10. run program - gives error: "The program can't start because
   libcurl.dll is missing... "
   11. Under "Project/Build Options/Search directories/Linker", add
   relative path to "myCurlGitDownload\curl\lib\"
   12. run program - it works!

There is only one minor problem left: when I compile the code and then try
to run the standalone .exe, it complains that "The program can't start
because libcurl.dll is missing from your computer."

If I copy libcurl.dll to the same directory as the .exe it works fine, but
I would rather bundle the libcurl.dll into the .exe.

I did try adding the CURL_STATICLIB compiler flag as described on
https://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur, but
that did not make any difference.

From searching on other sites, sounds like I might need a .lib file rather
than a .dll if I want to bundle it into the executable, but I did not see
any .lib files in the distribution. Is there a way to Make those?

Thanks again for all the help,

Greg

On Thu, Dec 1, 2016 at 7:40 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Wed, 30 Nov 2016, Greg Saunders wrote:
>
> 1. downloaded curl from https://github.com/curl/curl
>> 2. ran buildconf.bat (successfully)
>> 3. created new C project in codeblocks (main.c)
>>
>
> You seem to have skipped step 2a: build the library (and curl)
>
> It might work with just 'make mingw32' in the source tree root.
>
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-01