Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6026769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:29:38+00:00 2026-05-23T04:29:38+00:00

I can’t figure out how to properly add a static libcurl library to my

  • 0

I can’t figure out how to properly add a static libcurl library to my Code::Blocks IDE. I want it static because then no .dll files, which are not included in Windows by default, are needed during runtime of my program. I am using this libcurl:
http://curl.haxx.se/dlwiz/?type=lib&os=Win32&flav=- (minGW without OpenSSL)

Here are my global compiler settings: http://img845.imageshack.us/img845/1381/halpr.jpg

I am getting the following error:

ld.exe||cannot find -lCURL_STATICLIB| ||=== Build finished: 1 errors, 0 warnings ===|

when compiling this code:

include <stdio.h>
include <curl/curl.h>

int main(void)
{
CURL *curl;
CURLcode res;

curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
res = curl_easy_perform(curl);

/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}

Obviously it does not find CURL_STATICLIB, thu I got no idea why. I am not even sure if it was needed to add CURL_STATICLIB to my linker settings(I read it on other forums). I found some guys having same problem, but it isn’t properly answered on any place:

stackoverflow.com/questions/4176503/frustrated-with-libcurl

forums.codeblocks.org/index.php?topic=11391.0

old.nabble.com/gcc-working-with-libcurl-td20506927.html

forums.devshed.com/c-programming-42/linker-error-using-libcurl-698071.html

I am so tired of fighting with this, please help me.

EDIT:

Hello Victor, thank you for response!

I will try to be as detailed as possible, so there are no missunderstandings.
So, here is the image of the directory/folder tree for my C:\libs\ folder:

http://img199.imageshack.us/img199/6977/curl1.png

As you can see, it also includes build log, you will notice that the error this time is
different than the one I posted previously. It’s because I changed global compiler and build project settings.

My new Build Project settings: http://img863.imageshack.us/img863/4404/buildoptions.png
My new Global Compiler settings: http://img225.imageshack.us/img225/4926/curl2.png

I am sure I have configured these settings wrong and that’s why I can not compile it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:29:39+00:00Added an answer on May 23, 2026 at 4:29 am

    Okay, I managed to build your example successfully with libcurl using static linkage. The details involved to make this work are quite intricate — setting it up correctly can get tricky for the unwary.

    Here are the steps I used to make this work, be sure to follow them carefully:

    1. Go to Project build options->Compiler settings->#defines: type in CURL_STATICLIB. When this is defined the libcurl.h header will have its function signatures preprocessed to fit static linkage. Otherwise dynamic linkage is assumed and the mangled names then become _imp__*. The unresolved errors from your screenshot indicate it’s attempting a dynamic link rather than the desired static link.

    2. Under Project build options->Linker settings->Link libraries make sure it contains the following: curl, rtmp, idn, ssl, ssh2, crypto, z, ws2_32, wldap32, winmm, gdi32. Note that order is important. Due to a design deficiency of the gnu linker, the most dependant libraries need to be listed first followed by least dependant. Other linkers like msvc link and borland’s ilinker do not exhibit such issues — the libraries can be listed in any order.

    3. Under Project build options->Linker settings->Other linker options add in ‘-static’. This will make sure that the static version of ‘idn’ is used. If this switch is omitted then your compiled program could depend on ‘libidn-11.dll’ to run which probably isn’t what you want.

    At this point, you should be able to compile and link libcurl programs without any issues. A couple things worth mentioning,

    • Under Other linker options the other extra switches from your screenshot aren’t needed. ‘libcurl.a’ is already listed and covered by Link libraries.

    • The ‘libcrypto.a’ seems to cover the same references as the ‘libeay32.a’ so only one of them is needed. However, ‘libeay32.a’ causes dynamic linkage despite its larger size. If you want your application to be ‘fully self-contained’ use ‘libcrypto.a’ instead like in the screenshot.

    • If you wish to link dynamically in the future, just replace the listing with ‘curldll’ under Link libraries and remove the CURL_STATICLIB define. The extra libraries (eg. ssl, idn, rtmp etc.) aren’t needed since libcurl.dll already covers them.

    • You can avoid the tedious error prone setup of a new libcurl program by employing codeblocks’ user templates. (eg. File->New->Project->User templates)

    Hopefully this resolves any build problems you have with libcurl once and for all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I figure out if a function has already been assigned to an event?
Can't figure out how to do this in a pretty way : I have
Can someone recommend an up to date library for data Sanitization in PHP ?
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can someone guide me on a possible solution? I don't want to use /bin/cp
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can't work out a way to make an array of buttons in android. This
Can anyone help me trying to find out why this doesn't work. The brushes
Can we close all known/unknown connections to database with the code? I'm using Access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.