curl / Mailing Lists / curl-library / Single Mail


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

From: Greg Saunders <>
Date: Thu, 1 Dec 2016 17:11:17 -0600


Wow! THANKS for taking the time for such a detailed explanation. That
helped tremendously.

I downloaded from and it
all worked beautifully. And I did need

mingw32-make.exe mingw32 CFG=sspi-winssl

so thanks for your forethought in that.

I switched over to libcurl.a, and tried to add the CURL_STATICLIB compiler
flag, but the .exe still requires libcurl.dll - is that expected?

Compiler flags are:

[image: Inline image 2]

On Thu, Dec 1, 2016 at 1:37 PM, Ray Satiro via curl-library <> wrote:

> On 12/1/2016 12:09 PM, Greg Saunders wrote:
> 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 (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
> <>
> 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
>, 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?
> mingw32 users are also able to use the better maintained autotools style
> scripts ./buildconf && ./configure from MSYS (sometimes included with
> mingw) to build using the mingw gcc. The m32 makefiles you used are fine
> but they don't detect or enable anything extra by default, you are expected
> to specify it in a configuration using the CFG variable. You can open up
> the lib/Makefile.m32 or src/Makefile.m32 to see how it works and is
> documented. If I were you I'd use at least Windows SSL, SSPI and IDN
> options, like this
> mingw32-make.exe mingw32-clean
> mingw32-make.exe mingw32 CFG=sspi-winidn-winssl
> If your mingw is too old the import for WinIDN may not be available:
> ld.exe: cannot find -lnormaliz
> so skip it:
> mingw32-make.exe mingw32-clean
> mingw32-make.exe mingw32 CFG=sspi-winssl
> At this point you will end up with a libcurldll.a (import library for the
> dll) and a libcurl.a (static library). Your question about why staticlib
> doesn't do anything is because you explicitly specified the DLL library.
> Typically this is how you would build the example simple.c using the DLL:
> gcc -Wall -Wextra -o simple simple.c -I ../../include -L ../../lib
> -lcurldll
> static libraries it's complicated though because you have to know at link
> time all the dependencies. In the case of Windows SSL and SSPI and IDN it
> (usually) looks like this:
> gcc -DCURL_STATICLIB -Wall -Wextra -o simple simple.c -I ../../include -L
> ../../lib -lcurl -lcrypt32 -lnormaliz -lwldap32 -lws2_32
> *Please note the repo master branch is for development and should not be
> used for production.* What that means is if you are going to release your
> software you should instead build it with the latest curl release. On the
> download page [1] you can find the official release source and also some
> contributed builds. Sign up for release announcements [2]. It is also
> possible to build the latest release from the repo by checking out the
> latest release tag (git checkout). You can find the latest release tag by
> going to or you can automate
> it in a script like
> curl -fLsS --proto =https
> curl/curl/releases/latest | jq --raw-output ".tag_name | select(type ==
> \"string\")"
> [1]:
> [2]:
> -------------------------------------------------------------------
> List admin:
> Etiquette:

List admin:

Received on 2016-12-02